Regex Help Needed

Hi Team,

I just need to extract just the storenames just after the string “Add new store” from the below lines. My expected result is ABC,XYZ

Add new store ABC
Add new store XYZ
Change store FSFJ to FSFSFSFS
Change store rtrtrt to svdfdf

I tried with below regex and it gives me entire text
“(?<=Add new store)(.*)”
ABC,XYZ,Change store FSFJ to FSFSFSFS
Change store rtrtrt to svdfdf

@Teenu

Try this:

yourStr = “Add new store ABC
Add new store XYZ
Change store FSFJ to FSFSFSFS
Change store rtrtrt to svdfdf”

requiredString1 = yourStr.substring(yourStr.IndexOf("Add new store ")+"Add new store ".Length).Split(Environment.NewLine.TocharArray)(0)

requiredString2 = yourStr.substring(yourStr.IndexOf("Add new store ")+"Add new store ".Length).Split(Environment.NewLine.TocharArray)(1)

I do not see any issue with the expression that you gave.
I had tested the regular expression and getting the expected results.

Yes, it works fine with regex editor. Except that it takes/m/g characters in regex editor

Not sure why it doesn’t in code when it works in regex editor

Let me check in code and let you know the details.

Thank you so much

1 Like

Here is with code. The following regex expression worked.

(?<=\bAdd new store\s)(\w*)

1 Like

Hi Karthik,

I have used the pattern in the Matches activity as
“(?<=\bAdd new store\s)(\w*)” and input is my entire string:
“Add new store ABC
Add new store XYZ
Change store FSFJ to FSFSFSFS
Change store rtrtrt to svdfdf”

But I get only one store ie,ABC and not reading next line

Can you try in the following way.

Can you replace all new lines in your string into Space.
And then use the given regex pattern.

I guess it is failing to get from the new lines. Just a thought.

No luck:(