You could use
quotemeta() to make the regex work, as has been noted. Since you are searching for a fixed string, the
index() function offers itself as a simpler tool that does the job. There is no need to quote anything because
index() treats all characters equal.
if ( index( $_, $flag) >= 0 ) { # found it
Anno