I need a bit of a help with regex, fro example I have these strings:
And I need to get the numbers "8", "26", "1", but not the "1985" that's a year not a part number. I got this so far '/(\d+).?$/'
that works for picking the number but I do not know how to remove the string for preg_replace()
function, so it only returns the wanted numbers.
Edit: What if i wanted only the strings, so vice versa ?
Have a look at preg_match function, the third parameter is the array of matched items, as you enclose your numbers in brackets, you'll find them there. To be more precise, $matches[1] contains mathcing numbers, $matches[0] contains the whole matched expression.