Use regex in contain

st= " There are 300 word(s) , 600 books’
The numbers are changing in every string.
Can I use something like this -
b= st.tostring.contains(“[0-9]+ word(s), [0-9]+ books”) ??

How can i pass regex in a string ?

2 Likes

I don’t think String Contains can check for string patterns, it can just check for strings. Rather you could use Regex Match (which you might already know) which is more flexible and efficient.

It will be great if you can share an example/script. I tried ismatch ("[0-9]+ books) did not work . 0-9 is the regex,“books” is static.I am trying to compare a combination of regex and static text.

You may try below regex. It may not be 100% precise, but you can tweak as per your requirement.

\b\d+ word\(s\) , \d+ books\b

if you just need books

\b\d+ books\b

1 Like

Let me try …thanks !

RegexTest.xaml (6.6 KB)
Hi there @sampaddas
The attached workflow may assist you in utilising the “Matches” activity.

Thanks in advance,
Josh