I need to find a specific piece of text in a string. This text should have:
- 12 characters (letters and numbers only)
- the whole line must contain at least 3 digits
- 3 * 4 characters with spaces (e.g.
K9X6 6GM6 LM11 ) - each block from the above example must contain at least 1 number
- words like
this , line , spod should not be recognized

So, I ended up with this code:
preg_match_all("/(?<!\S)(?i:[az\d]{4}|[az\d]{12})(?!\S)/", $input_lines, $output_array); But it will not work for all requirements. Of course, I can use preg_repace or str_replace and delete all (!,?, #) And the number of loops if there are 4 or more, but I wonder if it is possible to do this with preg_match_all ...
Here is the line to search in:
?K9X6 6GM6 LM11
Correctly preg_match_all should return this:
K9X6 6GM6 LM11 K9X6 6GM6 LM11 K0X6 0GM7 LM12 K1X6 1GM8 LM13 K2X6 2GM9 LM14 K3X6 3GM0 LM15 K4X6 4GM1 LM16 K5X65GM2LM17 K9X66GM6LM11
working example: http://www.phpliveregex.com/p/bHX
source share