regex to block 2 patterns within n characters of each other -


what want create singular regex find 'cat' , 'mouse' in string if , if there between n , n2 chars between 2 occurrences.

what have tried (unsuccessfully) this:

cat{1,12}?mouse 

the goal register in sentence :

the cat , mouse played. 

but not in sentence:

the cat went out lunch , on way found mouse 

where space in regex??

cat[ ]{1,12}mouse 

not sure understood question correctly or not. if want consider characters(other newline) use dot .

cat.{1,12}mouse 

you can use word boundary around words if want avoid picking words xcat

\bcat\b[ ]{1,12}\bmouse\b 

Comments

Popular posts from this blog

css - I want to align grid in center -

python - SWIG function not printing output -

Contact Form PHP Email Script -