String matching using regex option

Hello,

I have a string “The balance to be paid is 246749637, 246?21819230, 246859?22575”.

I want to extract numbers starting from 246 followed by 6 digits. I want to remove ?21, ?22 from the above string.

The output should be: 246749637 , 246819230, 246859575.

Thanks,
Aditi

You can use regex matches

“?\d{2}” - Remove Quotes

This will match the ?21, ?22

Using regex replace you can replace those

Thanks

put \ before ?

Hi @AditiGandhi

For removeing ?21 you can use “246?21819230”.replace(“?21”,“”)

image

Cool,
Regards,
Gulshiyaa

hi,
find the attached xaml hope it solves your issue
Regex.xaml (6.2 KB)

2 Likes

Hi
The expression would be like this
If str_input = “246859?22575”
Then
str_output = System.Text.RegularExpressions.Regex.Replace(str_input,”(\W…)”,””).ToString

Cheers @AditiGandhi

2 Likes

Hello @AditiGandhi
You can do all of the processing using a single Assign Activity

Assign this to a string Datatype variable and you’ll get the output in this format

this is the code :-
string.Join(",",(System.Text.RegularExpressions.Regex.Matches(Strr,"\d+\?\d+|\d+")).Cast(of match).select(Function(r) System.Text.RegularExpressions.Regex.Replace(cstr(r.value),"\?\d\d","" ) ).ToArray)

What this codes does is first it takes the entire number with ? and the two digits than it checks one by one and replaces the question mark and the two digits

3 Likes

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