Reputation: 11
How do i find matches with any of -+/* symbols using preg_match?
I try
$stroke = '21+64';
$pattern = '/[+-/*]/';
preg_match($pattern, $stroke, $matches);
var_dump($matches);
but it doesn't work.. Thank you.
Upvotes: 0
Views: 37
Reputation: 42935
Have a try with that pattern:
/[+\-\*]/
You have to "escape" the -
and the *
, and you do that with a preceding "back slash" (\
).
Upvotes: 1