Unable to take the regex result

im unable to print the result of my regex
regex.xaml (13.6 KB)
this is my workflow
https://regex101.com/ this is the regex im using to print the next value of the supplier name from mail and want to store into a variable

please help me with this

thanks & regads
suhel

1 Like

Hi @Suhel_Khan, there is an error with your regex expression. Can’t use “+” in positive lookbehind.

Cheers.

@quihan
im using this regex
[\n\r].Supplier name :\s([^\n\r]*)

then its giving me this output

How are you accessing the match result?

by assigning it to a variable

Did you access it by index? For example, output variable of Matches called MatchedText.
To access it, it will be MatchedText(0).toString. If you expect more than one value, you have to use a For Each activity.

Cheers.

@quihan yes i have tried using index also but ended up with an error
Main has thrown an exception

Hi @Suhel_Khan, in that case, there is no match. Try printing your MatchedText.count, most probably it will be 0. It is good to have a if condition to check whether there is any match before accessing the variable.

Cheers.

hello @quihan sorry but there is match in my regex i have checked it in online debugger but in uipath
im not getting exactly what im looking for

Hi @Suhel_Khan, have you tried checking the count of the variable?

yes but too its not working

Do you mind sending me the Text result you are getting and the Regex you are using? I guess is how UiPath treat carriage return and new lines. On the safe side, you should use \s* to capture those.

regex.xaml (24.3 KB)
this is my work flow

The amount of goods which we have received have got some damage items.
Supplier name : Suhel khan
Item name : cupcakes
PO : #14
Received quantity : 100
Rejected Quantity : 11

this is mail conatin

regex result : regex101: build, test, and debug regex

Hi @Suhel_Khan, the text you sent actually works fine. The text you are receiving from the email content might have different format. Lets try something as simple as this.

\sSupplier name :\s(.)\s

regexTest.xaml (6.0 KB)

Hope this helps.
Cheers.

hello @quihan
thanks its working but its not syncing with my code
regexwork.xaml (24.1 KB)

check and please reply

HI @Suhel_Khan, what’s the problem?

it is not giving me the particular output @quihan

May I know what are you getting?

im getting the required output as well as the next text of my mailbody #please gothrough my workflow

The problem here is your Mail Text doesn’t recognise the \s. You might want to add an anchor (e.g. a text after your wanted text at your regex). I wont be able to test your workflow as I don’t have your mail text.