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

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -