For example I have the following string 1234567890
pattern is /1|2/
preg_match_all('/1|2/', '1234567890', $out)
gives
[0] ⇒ "1"
[1] ⇒ "2"
But I need to know only the number when the whole pattern occurs (1 time in this case). Is it possible to find it?
In other words I need to count how many times all pattern occurs
P.S.
for 'closers' and 'downvoters': the question is much wider then just regexpings
Another example:
string sdjka1gsdf1la5wlkasdfcmjsdc8fgvkj
I need to count how many times occurs set of letters a
, b
and c
, followed by digits.
As you can see in this example there'are three occurences - a1, a5 and c8.
So how I can count them?
Example 2:
String where 1 abcd when 1 123456 where 5 when 10 abdc
I need to count how many times whe*+one digit
occurs (in this case 3 times)