String manipulation to extract data

Hello

Need to extract the Ref ID No from below sample input. it will change dynamically

Invoice No: INV-12345
Ref ID = 67890
Transaction: TXN_45678

Hi Paul,

You can try with Regular expression in UiPath

https://regex101.com/

Regards,
Gokul

Hi paul,

Kindly check oput the below expression

Use this expression in the Assign activity

system.text.RegularExpression.regex.match(Inputstring,"(?<=Ref\sID\s\D\s)\d+").Tostring.Trim

Regards,
Gokul

1 Like

Hi @Paul_Mark

Please find the below regular expression:

strInput = "Invoice No: INV-12345
            Ref ID = 67890
            Transaction: TXN_45678"

strOutput = System.Text.RegularExpressions.Regex.Match(strInput, "(?<=Ref ID\s*\=\s*).*").Value.Trim()

Hope it helps!!

Regards
PS Parvathy

1 Like

Hi @Paul_Mark

Welcome to UiPath,

Try this-

refId = System.Text.RegularExpressions.Regex.Match(inputText, β€œ(?i)ref\sid\s[:=]?\s*(\d+)”).Groups(1).Value

If helpful, mark as solution. Happy automation with UiPath

1 Like

Hi @Paul_Mark

Welcome to UiPath community!

You can try to use linq functionality, use assign activity inside put
inputText.Split({Environment.NewLine},StringSplitOptions.RemoveEmptyEntries).Where(Function(x) x.Contains(β€œRef ID”)).Select(Function(x) x.Split("="c)(1).Trim).First

Use if condition and you will get your required output. If you face any difficulties feel free to ping here .

Happy automation!

1 Like

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