- The first question is:
I use http://www.phpliveregex.com/ to check the validity of my regular expression, and it finds more than one matching string.
I am doing this regex:
$lines = explode('\n', $text); foreach($lines as $line) { $matches = []; preg_match("/[0-9]+[AZ][az]+ [AZ][az]+S[0-9]+\-[0-9]+T[0-9]+/uim", $line, $matches); print_r($matches); }
on $text that looks like this: http://pastebin.com/9UQ5wNRu
The problem is that printed matches are just one match:
Array ( [0] => 3Bajus StanislavS2415079249-2615T01 )
Why is this doing to me? Any ideas what might solve the problem?
- Second question
Perhaps you noticed in the text not the usual alphabetic characters of the Slovak language (from pastebin). How to match these characters and select users who have this format:
{number}{first_name}{space}{last_name}{id_number}
how to do it?
Well, the first problem is fixed. Thanks @ chris85. I had to use preg_match_all and do this for the whole text. Now I get an array of all students whose names contain Slovak (English) letters.
source share