regex - php - count particular permutations -
i have strings :
431234412
what trying find instances of '1234' in each string numbers can used again long in order.
so instance, in above string there 2 instances of '1234' since '12344' can interpreted '1234-' or '123-4'.
i thinking of writing recursive functions maybe there simple way regex?
the regex quite simple:
$subject= '431234412'; preg_match_all('/(1+2+3+4)+/', $subject, $matches);
you find occurrences in array $matches
.
the +
behind each digit means, digit may repeated.
Comments
Post a Comment