Extract Name of a Month from string

Can anyone help me on how to extract only the name of the month that present in the string.
For example : My string is : “ABC_JAN_January_ Abc”
And my result should be : JAN

Thanks in advance.

If you know the string always has the following structure you can use stringVariable.split("_"c)(1).ToString

If there are other ‘_’ in the string before that this will not work.

Hi @TimK,
Here the problem is the string length changes every time .So we are not supposed to pass the integer value as 1 in split function.
Example: String1 : Abc_xyz_AUG_August_pqr .
Result : AUG
String2 : pqrs_abc_stu_JAN_January_def_jkl.
Result : JAN
Can you please help me in solving it.

The solution that occurs to me is creating an array with all 12 months, like {JAN, FEB, …, DEC}, and then splitting your string with '’ [stringVariable.split(""c)], and compare the two arrays which value they have in common and returns it…

@Bindhu Hello bindhu welcome to uipath community you can use regex like this [A-Z]{3} have a look Here


Use below method in Assign Activity



Hi @amaresan ,
Thank You , it works well

1 Like


Use lasted one… forgets to add ‘R’ in MAR( now edited)

For better results …make it input string as Upper and use it…

Ex yourinputstring.toupper put in assign activity

Then use that regex pattern which is given by me



Only issue could be if any of the months strings in the array appear in any other part of your string.

e.g. “pqrsdecimal_abc_stu_JAN_January_def_jkl”.ToUpper

will match DEC first

You may need to match more specifically such as (_JAN_|_FEB_|_MAR_|_APR_|_MAY_|_JUN_|_JUL_|_AUG_|_SEP_|_OCT_|_NOV_|_DEV_)

1 Like


Yeah You are Right. I forget that One …

Please add Bindhu your above post to let her know…

1 Like

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