I wanna check if a number exists in a numeric list.
For example:
the numeric list: 0, 2, 22, 122
I wanna know if '2' exists in the list, so I use this regexp:
(?<=|,)(\s*)(2)(?!\d)
We can simply test this in the MySQL like this:
SELECT '0, 2, 22, 122' REGEXP '(?<=|,)(\s*)(2)(?!\d)';
I got 'repetition-operator operand invalid' error from MySQL. Anybody can help me?
In PHP, it works well!
$str = '0, 2, 22, 122';
$reg = '(?<=^|,)(\\s*)(2)(?!\\d)';
$m = preg_match_all($reg, $str, $matches);
var_dump($matches);
Thanks~~~