The goal is to use grep and find all URL paths containing an underscore. Underscores in the query string are ignored. Examples:
Positives:
/abc_bcd/def/
/foo_bar_foo
/image_bar?s=color
/foo_bar
/foo_remover?s=foo_bar
Negatives:
/foo
/foo/bar/foo
/foo/bar/foo?s=foo_bar
/foo-supersizer
/foosupersizer
/foobar
/foo-supersizer?s=foo_bar
foo_bar
foo bar bar_foo
foo_bar_foo
This regular expression works, but applying it inside of grep (on macOS) fails to yield any files even though there are ones containing matching paths.
Regular expression: /^(?=[^?\s]*_)(?:\/[-a-zA-Z0-9()@:%_?\+.~#&=]+)+\/?$/gm
RegEx test: https://regex101.com/r/tIYoP7/3
Grep command: grep -r "^(?=[^?\s]*_)(?:\/[-a-zA-Z0-9()@:%_?\+.~#&=]+)+\/?$" .
Does grep require special formatting for regular expressions on macOS?