How to extract part of the text - Get Text activity

Hello all, how am I suppose to extract only year from the text I got?

As you can see, there are some text before and after 2013 year. I need to extract only year from this text.
What is the best option to extract year part of the text since I have many cases of extracting year(There are years from 2001 to 2019).
To get text from textboxes I’m using Get Text activity.


Use below Regular expressions to get year from that String.

1 Like

Fine once after getting the text with get text activity and stored in a variable named strinput
Use this expression in a assign activity
Stroutput = Split(strinput.ToString,” “)(2).ToString

Or do
Sometimes more words might come before the year term or another four digit come before year value
In that case use a assign activity like this
Str_output = System.Text.RegularExpressions.Regex.Match(strinput.ToString,”[2][0][0-1][0-9]”).ToString.Trim

Cheers @bp777

varText = new System.Text.RegularExpressions.Regex.Match("308 || 2013 SW Diesel", "
1 Like

Amazing again, thank you @Palaniyappan once again :pray:
Also, thank you all for your answers.

Cheers @bp777

1 Like

are you sure you will never have a text like this: 2018A || 2013 SW Diesel for example? Cause that expression will be wrong for you…

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