How to extract the account number

Hi Team,

I am extracting text using Get Text activity and storing it in a variable “Account_Number”. The extracted value is in the format: “Account Number is AC2025-7537366”. I need to extract only the numeric values that come after the prefix “AC” and including “AC” Can you please suggest the best way to achieve this in UiPath?

Use Split method like
YourVariable = Account_Number.Split("AC")(1)

And if you don’t want that - in between the use this

YourVariable = Account_Number.Split("AC")(1).Replace("-", "")

Cheers

1 Like

@iamiishita,

Use an Assign activity:
strValue = System.Text.RegularExpressions.Regex.Match(Account_Number,"AC\d+").Value
This will extract AC along with the numeric part.

1 Like

Tried this however it is not working.

This is working thank you @Mir.Jasimuddin.

Ohh sorry I thought you don’t want to include that “AC”.
For that use this Account_Number.Split(" ").Last.Split("-")(0)

Cheers

Hi @iamiishita

Use this regex

StrValue = System.Text.RegularExpressions.Regex.Match("AC2025-7537366", "^[A-Z]+\d+").Value

You will get AC2025 as an output.

Thanks!

No problem I got it now

1 Like

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