Get a substring from a string

Hi Champs,

Stuck on a part of my code help needed.
Any leads would be highly appreciated.
My problem is: Suppose their a datatable which has column TEXT, the values of text can be as follows:

  1. Q1 ExcessDefCfgdftrfhhjkui htyuo V 2343555 D 72
  2. Q1 ExcessDefCftreyvhsvhhh hjkui htyuo V 2347679 D 87
  3. Q1 ExcessDefCfgdftrfhhjghdfdjjkui htyuo V 2343557565 D 72765

    and so on
    thus From Column Name “Text” which can have above values extract the digits after Character “V” but prior to Character “D”.
    so the result should be:
  4. 2343555
  5. 2347679
  6. 2343557565

thus above result is expected . Any leads would be highly appreciated

Thanks !!! :slight_smile:

You can get this in a For Each Row activity by assigning a string variable to the following expression:

System.Text.RegularExpressions.Regex.Match(row("TEXT").ToString, "(?<=V\s)\d+(?=\sD)").Value.

4 Likes

thanks a lot @Anthony_Humphries its working !!
Just had a query if in the similar way i want the numbers which are after character “D” for ex:

  1. 72
  2. 87
  3. 72765

What changes do i need to make in the regex ?
thanks cheers !!

System.Text.RegularExpressions.Regex.Match(row("TEXT").ToString, "(?<=\sD)\d+").Value.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.