I am not very good at regular expressions. Can somebody help me with this?
$string = '1,2,3,4,7,8,10,11,14,17,18,19,22,23,26,29,30';
preg_match('/(\d*,*)(2,)(\d*,*)(4,)(\d*,*)(8)/', $string);
All the time this string has to be string, can’t be array or anything else. Let’s say I am looking for numbers 2, 4, 8 (but not 18). I am using PHP and the preg_match function.
Here is solution with array:
And solution with preg_match: