Regex Pattern for the following

Hi All,

I have a certain text like this
Input :
TOTAL FTC COST 1568324.01
TOTAL FTC COST(Trnc/Opt) 1500723.02
TOTAL MEAL COST 842359.80
TOTAL HOTEL COST 1493121.74
TOTAL TRANS COST .00
TOTAL DBLTOWN COST .00
TOTAL COST 3903805.55

I want TOTAL MEAL COST value (Example here : 842359.80)

Help me in this

Thanks in Advance!!!
Srikanth

@Palaniyappan @lakshman

2 Likes

Fine
welcome to uipath community
if the input text is
in_text = “Input :
TOTAL FTC COST 1568324.01
TOTAL FTC COST(Trnc/Opt) 1500723.02
TOTAL MEAL COST 842359.80
TOTAL HOTEL COST 1493121.74
TOTAL TRANS COST .00
TOTAL DBLTOWN COST .00
TOTAL COST 3903805.55”

then use a assign activity like
out_text = in_text.Split(Environment.Newline.ToArray())
where out_text is a string array

then use a for each row loop and mention the above variable as input and change the type argument as string in property panel
–inside use a if condition like
item.contains(“TOTAL MEAL COST”)
then in the THEN part use a writeline like
Split(item," ")(3).ToString

1 Like

Hello @Srikanth_prem,

You can also get the value using a regex expression: (?<=TOTAL MEAL COST)(.*)(?=\n)

There are a lot of samples on the forum:
https://forum.uipath.com/search?q=regex%20between%20words

Thanks and best regards,
Susana

3 Likes

@Susana

Thanks a lot !!!

One more doubt

How can i get regex match for this

_AS CP 639.63 614.52 599.49 576.09 40.30 38.56 24.53 0.23 6.72 8.80
_AS FO 639.63 614.52 599.49 576.09 40.30 38.56 24.53 0.23 6.72 8.80

Here i want the value 639.63 only from the two lines(After _AS CP)

Help me in this

Thanks in advance
Srikanth

1 Like

Same with the above steps but while getting the value in loop without if condition and directly with a assign activity like this
out_value = Split(item,” “)(1).Tostring.Trim

Hope this would help you
Cheers @Srikanth_prem

1 Like

Hi @Srikanth_prem.

There are a lot of options to get those values, you can use https://regex101.com/ to test your regex expressions. One example (?<=_AS … )(\w|\d|\n|[(.)]| )+?(?= ) or (?<=_AS CP |FO )(\w|\d|\n|[(.)]| )+?(?= ).

Thanks and best regards,
Susana

@Susana

Thanks a lot!!!

I tried with other pattern, but this one really understandable.

Thanks you
Srikanth

1 Like

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