At my company we recently noticed that one developer was not using language files but putting text directly in the code.
My idea was to search for words between quotes that have atleast 1 or more whitespace in them. But I got kinda stuck with
("|')(\w|\s{1,})*('|")
this does match text but does not require that it has atleast 1 word and atleast 1 whitespace (so it matches about anything between quotes). Can anyone help me out?
The language I want to use for this is PHP (or I could do a notepad++ search)
If you want to match single or double quoted strings (without escapes) that contain a "word" and a space you could use:
"(?=[^"\n]*\w)(?=[^"\n]*\s)[^"\n]+"|'(?=[^'\n]*\w)(?=[^'\n]*\s)[^'\n]+'
In PHP it would look like:
preg_match_all("/\"(?=[^\"\n]*\\w)(?=[^\"\n]*\\s)[^\"\n]+\"|'(?=[^'\n]*\\w)(?=[^'\n]*\\s)[^'\n]+'/", $string, $matches);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With