mr.baby123
mr.baby123

Reputation: 2312

match random lengths of string using regex (preg_match)

i have need to split string, by regex:

  1. split digits together
  2. split letters together
  3. [ each part should contain between 3-5 chars RANDOMLY ]
so if i have:
'aaa555aaaaaaaaaaaaaaaaaaaaaa55555555555555555'

so the result MIGHT be:
'aaa 555 aaa aaaa aaaaa aaaa aaa aaa 55555 555 555 555 555'

(the last item might be 1-2 characters length).

so i started with regex:
preg_match_all('/([a-z]+)|([0-9]+)/')

the question how to apply the random part. if it is possible... :)

Upvotes: 0

Views: 31

Answers (0)

Related Questions