Help with Regex matching

Facing some problem with a regex match. Trying to match the first part of the text (excluding the many blanks in the beginning) ending with the comma. The text will always be different but the format (spaces in the beginning and ending with comma) the same.

" Tamramaa Starp Concert Apple - CMP196-GTR, lackerad i Gloss Cherry Red finish.Kppnsert virvel"

…I want to match: “Tamramaa Starp Concert Apple - CMP196-GTR”
I thought ([^ ])[^.,]+ would work perfectly and using Regex-validators I get the wanted result but using Uipath it doesn’t work. Any advice?

Hi @HenrikX,

If you are getting the mentioned string value in a string variable then use that stringvariable.Trim() - this will remove the leading spaces.

Then try with the regex you are using.

Thanks, yes the spaces is not a problem. It’s matching up to the “,” that is my issue mainly.

@HenrikX,

Try with the regex as showed in the screenshot.

1 Like

Hi @HenrikX
Try this REGEX
image

Regards,
Aditya

Thank you! That was close. Just that it included the comma which it shouldn’t (I can solve that easily)

1 Like

Actually I did not get it working in UiPath. I don’t know why.

Hi @HenrikX

Take an assign activity and write this in value System.Text.RegularExpressions.Regex.Match(variable,“(?sim)(?<=").*(?=,)”).Value

Try this and let me know.
If this helps mark this as a solution.

Regards,
Aditya

1 Like

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