How to split a string in uipath by using Regular Expression

Hi Team,

string:abcde1234fghij6789klmnop456666

I want to extract or split a above string by usin regular expression in my code.Can you please help me how to do that?

Thanks in advance

Hello @cheersrpa,

What is the output do you want to get? Only the numbers?

Regards,
Susana

1 Like

hey please refer this links:


Hi @cheersrpa,

When you’re asking any question, it is required that you give us all the necessary information. You told us you needed to split this string, but you never told us HOW you want it to be split or WHAT you want it to be split into. What’s your required OUTPUT? All these questions are necessary to be answered first before anyone can give a good resolution to your problem.

Also, please go though this: How to ask a good question?

1 Like

hi @susana

the output should be only the numbers

@cheersrpa Follow attached xaml file

Main.xaml (7.0 KB)

Generic steps to follow whenever you want to use regex with UiPath:

Step 1: Write regex for the pattern of string you want to extract (in this case, those are only numbers). The Regex expression to use: “\d+”

Step 2: Just pass THIS Regex and your INPUT to a “matches” activity in UiPath. The output you receive will be an iEnumerable list of matched numbers (say iMatches)

Step 3: Use an If condition to check if iMatches.count>0.

Step 4: In the then part of if, use a for each statement and loop through all the matches.

Step 5: when using the matched values, do remember to convert them to string (console.writeLine(match.toString))

4 Likes

hey @siddharth,

thank you so much for the help.I tried your steps i got the output.

1 Like