Extract word using regex

i have string
str = “Text sopp+sopp Ref: 123456 Text”
i want to extract “sopp+sopp Ref: 123456”
i have have this so far
but when i run i get this error

can anyone help?

try this instead

if you print
you should get
sopp+sopp Ref: 123456

That works perfectly.
i dont suppose i could have help with one more?
strText = “Text TSM001-123456 Text”
im trying to extract “TSM001-123456”
i have this so far
System.Text.RegularExpressions.Regex.Matches(strText, “TSM001–\S*”)

Thank you

you can use (TSM001-\S+)

seems like you jsut want to extract the text between "Text " like this

if thats the case just use the below regex to handle all your cases, that way you dont need a separate regex for each case


sometimes it may not be between ‘text’
it could be between any string

It will only look for what we have given in the expression

1 Like

thank you

1 Like

Your Welcome @Rowley101 and thanks to @jack.chan

My bad this one now is perfect
Happy Automation…!


what is the difference from the previous one?

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