I need help to design the regular expression syntax for a particular pattern

Hi All,

I am working on a complex project, where it required regular expression(Regex) syntax to be used on a particular text to trim and capture string only which is dynamic in nature. Please find my text down below and help me to find the perfect regex syntax to get the value.

Total nett amount: EUR 13.02
Total incl. VAT: EUR 13.02
Ship from: FR
Ship to: PL
UL. LUBELSKIEJ 4
HERR HERR JACUB NOWACKI
Incoterms:
Lane ID:


Billing Party: 8888
Customer ID: 0000
Item: 1 12.06 EUR
480 TRANSPORTATION
VAT 0% 0 X
0000000000000000
00000000000000
Service: U
Ship date: 0000000
Weight (gross / nett): 1.50 / 1.50 KG
Amount: 1 EA
EXPRESS WORLDWIDE eu
FUEL SURCHARGE
Item: 1 0.96 EUR
203 FUEL SURCHARGE
Weight (gross / nett): 1.50 / 1.50 KG
Amount: 1 EA
EXPRESS WORLDWIDE eu
FUEL SURCHARGE

Here I need to capture which string is present after (Ship from: , Ship to:, Item1:) only.

I have tried many ways, but am struggling. So I desperately need help to complete it.

Thanks,
Baruna Kumar Panda

Hi @Panda_Baruna_K ,

Have you tried using the Below Regex Expressions :
For Ship from field :

(?<=Ship from:).*

For Ship to field :

(?<=Ship to:).*

For Item field :

(?<=Item:).*

Hi,

I have already used the syntax (?<=Ship from:).*

and it is returning string : FR TE CONNECTIVITY SOLUTIONS GMBH PROC NOT SUPPLIED

I need only (FR) by trimming other than this.

there am struggling.

Thanks

Hi @Panda_Baruna_K

Ship From

System.Text.RegularExpressions.Regex.Match(Inputstring,"(?<=Ship\sfrom:\s)(\S+)").Tostring

image

Ship To

System.Text.RegularExpressions.Regex.Match(Inputstring,"(?<=Ship\sto:\s)(\S+)").Tostring

image

Item

System.Text.RegularExpressions.Regex.Match(Inputstring,"(?<=Item:\s).*").Tostring

image

Regards
Gokul

@Panda_Baruna_K , In the Data provided above, you have only mentioned FR, there were no additional data for Ship from field.

Could you let us know why are we only interested in FR ? Is it because it is the First Word ? Or is it because it matches the list of keywords that needs to be matched ?

Try this out @Panda_Baruna_K

System.Text.RegularExpressions.Regex.Match(Inputstring,"(?<=Ship from:\s)\S{2}").Tostring

Hi,

Sorry for the inconvenience, Actually that is a two digit country code, which i need to extract and use for further operation in my project. And please learn it, that the two digit is dynamic may change, so I need to trim between the (Ship from: & the details mentioned there.

I hope am clear. I really need support to fix the issue.

Thanks

HI Gokul,

Let me try, I will get back to you. Thanks for the input.

Thanks,
Baruna K Panda

Hi @Panda_Baruna_K

Update on the expression Ship From & To

(?<=Ship from:\s)\S{1,5}

image

Regards
Gokul

1 Like

@Panda_Baruna_K ,

In that case, you could check with the below Expression :
Capturing the first word :

(?<=Ship from:)\s*\w+

If restricted only to two letters :

(?<=Ship from:)\s*\w{2}

You could apply the same for Ship to field, if the same logic applies.

Let us know if it doesn’t work. Also do perform Trimming of the value once captured.

1 Like

Hi Gokul,

I am able to capture the data & storing it in a IEnuramable variable. But the out put it is giving is.

{
“message”: “System.Linq.Enumerable+d__97`1[System.Text.RegularExpressions.Match]”,
“level”: “Information”,
“logType”: “User”,
“timeStamp”: “10:55:36”,
“processVersion”: “1.0.0.0”,
“jobId”: “4a16d1ff-c499-491b-82f6-27846a0e6440”,
“robotName”: “DevBot009”,
“machineId”: 2,
“fileName”: “test2”
}

I have tried to capture variable.ToString also. It is giving same value. Could you please help me…

Thanks,
Baruna K Panda

Both are working, thanks but the output is in

System.Linq.Enumerable+d__97`1[System.Text.RegularExpressions.Match]"

even after binding with to String also.

Hi @Panda_Baruna_K

Can you share the expression screenshot used in the flow.

Regards
Gokul

Try with Value

System.Text.RegularExpressions.Regex.Match(“InputString”,“(?<=Ship from:\s)\S{1,5}”).Value

Regards
Gokul

Try like this in the message box

shipfrom.Value

Regards
Gokul

it is saying compilation error. As Value is not a member of Sytem.collection.Generic.IEnumerable

Hi @Panda_Baruna_K

Try pass like this shipfrom(0)

Refer the XAML file

MatchesActivity.xaml (5.2 KB)

Output

image

Regards
Gokul

1 Like

Hi Gokul,

Sorry for delay response, due to some emergency I couldn’t respond you on time.

Your solution is working. Thank you so much for your help. I truly appreciate that.

Thanks,
Baruna K Panda

Great @Panda_Baruna_K

Kindly close this topic by marking solution

Regards
Gokul