Want to extract particular word from string. Below are the format of string

JUPR POLE (01-31) PERMIT REQUIRED TO OVERLASH FRONTIER CABLE TO 31 POLES OWNED BY NIPSCO. P-35241

P-21165 ODOT US-23 MM:02.670

P-35955 LENAWEE COUNTY (CANAL ST)

Permit required to overlash to 12 poles owned by TIPMONT REMC. P-27526 JUPR

I want to extract text P-XXXXX

Hi @Puneet_Singh

Use Matches activity and set the Input property to the string that you want to extract the text from. In the Properties pane, set the Pattern property to the regular expression pattern P-\d+ and the Result property to a variable of type MatchCollection.
Then use Add a For Each activity to loop through the matches and set TypeArgument property to System.Text.RegularExpressions.Match.

Inside the For Each activity, you can access the matched text using the Value property of the current item.

Thanks!!

@Puneet_Singh

Please try this to be more precise with 5 numbers…You can use matches activity as well

System.Text.RegularExpressions.Regex.Matches(str,"P-\d{5}")

The output would be of type IEnumerable(Of Match) which can be accessed by using for loop anf change type argument to Match

cheers

System.Text.RegularExpressions.Regex.Matches(PermitID,“P-\d{5}”).ToString
Trying this and its not working

@Puneet_Singh

.Tostring will not give you output

The output type of this is IEnumerable of match

So create a for loop and pass this expression in in argument

Now change type argument to match

Then inside use currentitem.value to get each value for each iteration

You can assign the output to variable and usw variable as well…in for loop

Variable type ienumerable(of match)

Cheers

Assign Activity
arrValues | String Array =

System.Text.RegularExpressions.Regex.Matches(PermitID,"P-\d{5}").Cast(of Match).Select(Function (x) x.Value).ToArray()

in addition:

Regex.Matches will return a result of MatchCollection: Docu

Also feel free to browse through:

PermitID is variable which is storing single string and from that i am try to get that P-XXXXX value.
Each time the string change

When it is needed to log a string array/list we can do: Strin.Join(“|”, YourStringArrayOrList)

Dont know reason but its not working.

I am getting string from DB and storing single string in variable. For eg variable is containing “UNION TOWNSHIP P-21915”
Now from this string i want P-21915

Above string change for next record but i want to extract the same thing mean value starting P and having 5 numeric character.

here we cannot interact as we don’t know what is not working. But with the given link and the mention of debugging and working with the debugging panels you would be able to detect the issue. Also, you can prototype/test the different statements e.g. within the immediate panel

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