How to copy only the words that match the pattern in the data of the Text file and paste it into Excel?

I have a text file Inside there is text “123CAT456789”
I want to copy only the word “CAT” into a text file automatically, what should I do?

Hi @Famui_Yanisa, welcome to the Community.

Please try the following expression in the Assign activity:

extractedWord = System.Text.RegularExpressions.Regex.Match(yourfileNameText, "\bCAT\b").Value

Hope this helps,
Best Regards.

Hi @Famui_Yanisa

Try this

image

1 Like

Hi
Please try the following expression in the Assign activity:

extractedWord = System.Text.RegularExpressions.Regex.Match(yourfileNameText, "\d*CAT\d*").Value

1 Like

@Famui_Yanisa

Another alternate approach:

outputText = System.Text.RegularExpressions.Regex.Match(yourFileText, "(?<=\d)CAT(?=\d)").Value

Hope this helps,
Best Regards.

1 Like

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