Regex to find first word that contains number

Hi All,

please help to provide regex to find first word from sentence that contains number.

for ex : ZW Sep23 - ZC Dec23 Inter-Product

i want to find : Sep23

Thank you.

please give more clarification for more accurate solution
Usha

syste.text.regularexpression.regex.match(your variable,“(?<=ZW).*(?=ZC)”).value.trim

in assign activity store the above in variable

Hi Usha,

The first word ‘ZW’ constantly changes

‘ZC’ also constantly changes, I only need the word with number

You can call them by index whichever value you want

only the first one, the second is not included

Hi,

How about the following expression?

System.Text.RegularExpressions.Regex.Match(strData,"\w*\d\w*").Value

Regards,

Hi Yoichi,

it can’t work if the word is double

image

Hi @Suastrian_Dika

[A-Za-z]+\d+(?=\s*\-)
image

Hi,

Did you check it in regex101? regex101 highlights all matched string.
Can you try the following expression? This returns only first match.

System.Text.RegularExpressions.Regex.Match(strData,"\w*\d\w*").Value

Regards,

Hi,

okok, thanks for the explanation.

Regards.

Hi,

FYI, in regex101, if turn off global option, the first match is highlighted as the following

Regards,

Hi @Suastrian_Dika

You can use the below one with regular expression.

- Assign -> Input = "ZW Sep23 - ZC Dec23 Inter-Product"
- Assign -> Output = System.Text.RegularExpressions.Regex.Match(Input.toString,“(\w+\d+)”).value

Check the below workflow for better understanding.

Hope it helps!!

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