mercredi 6 mai 2015

Regex Multiple Matches PHP

Im trying to get all numbers from a string, having - or _ before the number and optional - _ space or the end of string at the end of the number.

so my Regex looks like this [-_][\d]+[-_ $]?

My problem is, i dont match numbers right after each other. From a String "foo-5234_2123_54-13-20" i only get 5234,54 and 20.

What i tried is following (?:[-_])[\d]+(?:[-_ $])? and [-_]([\d]+)[-_ $]? which obvoiusly didnt work,im looking for hours now and i know it cant be that hard so im hoping someone can help me here in short.

If that makes a different, im using php preg_match_all.

Aucun commentaire:

Enregistrer un commentaire