Reputation: 253
I need to have a regex that finds strings in quotes and they also need to contain specific substring. For example the substring could be "joe".
"123joe456" -> true
123joe456 -> false
"joe" -> true
"1joe" -> true
"joe2" -> true
"jo2e" -> false
Help is appreciated. Thanks!
Upvotes: 0
Views: 51
Reputation: 6753
This:
\".*(?<![a-z])(joe)(?![a-z]).*\"
Demo.
Will not match joe
in "heyiamjoe"
Or if you don't want that, simply use ^\".*joe.*\"$
Upvotes: -1
Reputation: 11116
like this
^\"\w*(?=joe)\w*\"$
demo here : http://regex101.com/r/jA9hC5
Upvotes: 2