Use regex in contain


#1

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

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.


#3

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.


#4

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


#5

Let me try …thanks !


#6

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

Thanks in advance,
Josh