I have the following string:
SEDCVBNT S800BG09 7GFHFGD6H 324235346 RHGF7U S8-00BG/09 7687678
and the following regex:
preg_match_all('/\b(?=.+[0-9])(?=.+[A-Z])[A-Z0-9-\/]{4,20}/i', $string, $matches)
What I'm trying to achieve is to return all of the whole "words" that:
/
-
Unfortunately, the above regex returns purely alphabetical and purely numeric words as well:
Array (
[0] => Array (
[0] => SEDCVBNT
[1] => S800BG09
[2] => 7GFHFGD6H
[3] => 324235346
[4] => RHGF7U
[5] => S8-00BG/09
)
)
I don't want SEDCVBNT
or 324235346
to be returned.
Here is the raw regex: \b(?=\S*?\d)(?=\S*?[a-z])\S+?(?=$|\s)
preg_match_all('/\b(?=\S*?\d)(?=\S*?[a-z])\S+?(?=$|\s)/i', $string, $matches)