Getting Substring from String

Hi,

I have a really long string. It looks like:
2020-01-01 12:00:00 ABCDE123 And there is some text

This string contains lots of similiar linies.

I need to extract from this string this “ABCDE123”. It is always at the beggining, always in the same place. Should I use here Regex or simply take characters from 21 to 28? When yes, how to do this?

Thanks for help,
Marek

Hi,

Hope the following helps you.

Regex

System.Text.RegularExpressions.Regex.Match(text,"(?<=^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} )\w{8}").Value

Substring

text.Substring(20,8)

Which is better depends on your condition.

Regards,

1 Like

Hi @Marek_Matuszak,

Yes you can use REGEX here following is for your reference
image
if this solves your query then mark this as solution.
Happy Automation!
Regards,
Aditya

1 Like

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