Regular expression to the following text

HI ,

I have the following text.

“balance jan is $52695.23
balance feb is $1203569.25
Ending balance april month is $252698.23
for confirmation”
out of this text I need to get the values which is beside the ending balance. i.e $252698.23

I tried of writing the regular expression to get the text that starts with “En” and ends with “.23” two decimal points but some where is going wrong.
Can anyone help in getting text starting with en and ending with two decimal points.

Thanks and Regards,
Srikanth

@srikanth999

Try this:

String str = “balance jan is $52695.23
balance feb is $1203569.25
Ending balance april month is $252698.23
for confirmation”

str.Split(Environment.NewLine.ToCharArray)(2).Split(" ".ToCharArray)(5)

1 Like

Try using this:
(?=Ending balance).*(\$.*)
And get 1st capturing group.

Also, for regex testing use regex101.com
for this example https://regex101.com/r/qeKrN6/1

2 Likes

Hi @srikanth999,
Is this what you are looking for?

.\d{4,}.\d{2,}

1 Like

Hi @srikanth999

You can use below regex pattern in Matches activity to take text between “Ending balance” and “for confirmation”.
(?<=Ending balance).+?(\n)(?=for confirmation) as shown in screenshot.

pattern
and use split in assign
Result (String) = (item.ToString).Split({" "},StringSplitOptions.None)(4) to get only $252698.23 (From highlighted text)

I’m attached my workflow for your better understanding: Regex.zip (11.5 KB)
I hope this will help you :slight_smile:

1 Like

The below regular expression should gives you the amount in group 1.

(?<=Ending balance).*(\p{Sc}[\d,.]+)

\p{Sc} matches any currency sign.

See it on regex101 https://regex101.com/r/h5daRy/1.

3 Likes