Extracting value using REGEX

As i use REGEX pattern to extract the value from the text.
I am using a general regex pattern inside for each .

B_Identifier (GLN)LJFDLOIEUWURWI824038204830284083dsf
for this text B_Identifier (GLN) is a field name and LJFDLOIEUWURWI824038204830284083dsf is a value but I can’t use this in regex pattern because of “( )”.
“(?<=(”+field_name+“))(.*)”-This is the general pattern I use.Each time the field name is getting changed.

Head.txt (2.7 KB)

Hi @agathiyanv

What is the output here?

System.Text.RegularExpressions.Regex.Match(YourString,“\S.+)”).tostring

image

Regards
Gokul

@agathiyanv

How about this expression?

System.Text.RegularExpressions.Regex.Match(YourString,“(?<=\))(\S+))”).Tostring

image

Regards
Gokul

For this field alone you created a pattern but how can I use inside loop??

Hi,

Can you try to use System.Text.RegularExpressions.Regex.Escape method, as the following?

System.Text.RegularExpressions.Regex.Match(yourString,"(?<="+System.Text.RegularExpressions.Regex.Escape(field_name)+").*").Value

Main.xaml (5.7 KB)

Regards,

I already use multiple if condition for this approach, I need a pattern that will work for all cases.

Thank you for this,But i already use two patterns inside loop so I don’t want to make it complicate further.Is there any other way to get the data by doing modification in this pattern “(?<=(”+field_name+“))(.*)”

Hi,

How about replace field_name with System.Text.RegularExpressions.Regex.Escape(field_name) as the following?

"(?<=("+System.Text.RegularExpressions.Regex.Escape(field_name)+"))(.*)"

As field_name contains regex special character : ( and ) , basically need to escape if have it recognized as non-special character.
And if you can create list of field name, the workflow might be as the following.

Regards,

can we use the pattern inside is matches activity??

Hi,

can we use the pattern inside is matches activity??

Yes, as the following.

Please note that RegexBuilderWizard doesn’t support such method.

Regards,

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