How do i get multiple matches using regex in assign activity

I am using assign activity and i want to get multiple match and store it into an collection type variable
Closing balance as 30-Jun-2023 18,444.386
Blocked Amount as 03-Jul-2023 0.000
Available Balance as 03-Jul-2023 159989.386

I want to extract closing and available balance from above text using single assign activity

@Goku

Try this

System.Text.RegularExpressions.Regex.Matches(str,"[\d,]+\.\d+")

cheers

what variable should i assign it to

@Goku

IEnumerable of Matches

image

How do i store it in a string array ?
And then use its index to access the collection?

@Goku

No need to store in string array

Use for each loop to iterate

H! @Goku

You can try like this .
use the assign activity and create a variable and value you can provide like this = System.Text.RegularExpressions.Regex.Matches(Input,“[0-9,]+.[0-9]+”)
it will be in collection so based on index you can call like this
1.System.Text.RegularExpressions.Regex.Matches(Input,“[0-9,]+.[0-9]+”)(0).value for getting Closing Balance
2…System.Text.RegularExpressions.Regex.Matches(Input,“[0-9,]+.[0-9]+”)(2).value for getting Available Balance

For reference you can check below image…

1 Like

@Goku

You can use like this to store in string array

System.Text.RegularExpressions.Regex.Matches(str,"[\d,]+\.\d+").Select(function(x) x.Value).ToArray

cheers