Extract Data out of a string

Hello guys,
I am completely new in UI Path programming. For my automation I’d like to extract some figueres.
For example the string (folder name) is called “ABC_A.00135.A20_TestAutomation” and I’d like to extract,
and copy just the “A.00135.A20” part.

Is there a way to solve this?

Thanks already!

@marco.roensch
Welcome to the forum

regex can help:
grafik

[CheatSheet] - System.Text.RegularExpressions | RegEx - News / Tutorials - UiPath Community Forum

Hi @marco.roensch ,

Try this:

system.Text.RegularExpressions.Regex.Match(InputString,"(?<=_).*(?=_)").Value

Regards,

Hi @marco.roensch

Welcome to UiPath community !

How about this Regular expression?

System.Text.RegularExpressions.Regex.Match(YourString,"(?<=_)\S+(?=_)").Tostring

Regards
Gokul

Thanks for your warm welcome :slight_smile:
This helped me a lot. But what have I to type in if there are more underlines in the string?
For example:
ABC_A.00135.A20_TestAutomation_VRX_Battery_OFT
and I’m still looking for “A.00135.A20”

Hi @marco.roensch

Try with this one

System.Text.RegularExpressions.Regex.Match(YourString,"(?<=_)\S+(?=_TestAutomation)").Tostring

Regards
Gokul

Hi Gokul,
excuse me for not beeing precise enough. This was just one possible case. In my case, there are plenty of folders with different name endings. So it isn’t alsways _TestAutomation. It could be: _VW_123 or _Audi_135 and so on. But I am looking for a general term to seperate the string between the first and the second underline. :slight_smile:
Thanks for your time !

Share the sample input and output

Good thread here

I highly recommend the free training on the UiPath Academy web site.

Input: Spring_A.00123.A20_VW Project Output: A.00123.A20
Input: Weber_A.00156.A20_Compound2x Output: A.00156.A20
Input: Mueller_A.01556.I20_ZX_59_CS Output: Output: A.01556.I20

Hi @marco.roensch

How about this expression?

System.Text.RegularExpressions.Regex.Match(YourString,"[A-Z]\.\d+\.[A-Z0-9]+").Tostring

Regards
Gokul

If it’s always gonna start with A and follow the same pattern, use this:

System.Text.RegularExpressions.Regex.Match(YourString,“[A-Z].\d{0,}.\w{0,}”).Tostring.Trim(“_”.ToCharArray)

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