[Solved] Get substrings from an array rows, Regex? [closed]


$str="2015/2016-0 5 Gruuu 105 Fac Cience Comm 10073 Com Aud 103032 Tech Real TV 4 First Time feb First Quad 6.0 1 Lory Johnson, Nicholas 1334968 47107453A Cory Stein, Hellen Monster Cr. pie 5 a 3-2 08704 Iguan NewYork [email protected] [email protected] 617788050 Si 105 / 968 17/07/2015 0";

Get 6 numbers:

preg_match('~\d{6}~', $str, $matches);
print_r($matches);

Get “get the two strings before the comma and the string after the comma and before the 7 numbers that always go together”:

preg_match('~([^\s]+\s+[^\s]+)\s*,\s*([^\s]+)\s*(\d{7})~', $str, $matches);
print_r($matches);

The outputs:

Array
(
    [0] => 103032
)

Array
(
    [0] => Lory Johnson, Nicholas 1334968
    [1] => Lory Johnson
    [2] => Nicholas
    [3] => 1334968
)

3

solved Get substrings from an array rows, Regex? [closed]