Reputation: 630
How would you preg_match for the symbol combination |~| or %*|
$harms = 'i.e. flow of electricity in contact with person(s)dsn fds fsdnfsnd fsd fmnds f|~|mnsdf <br /><br />ajshajkhsjkahs|~|';
if(preg_match('#\|~\|#', $harms)) {
echo 'true';
}
Upvotes: 0
Views: 2515
Reputation: 33904
You need to escape special chars in RegEx with a backslash \
:
preg_match('#\|~\|#', $s);
preg_match('#%\*\|#', $s);
You could also use preg_quote()
to escape special chars:
preg_match('#'.preg_quote('|~|%*|','#').'#', $s);
Upvotes: 1