lundi 27 novembre 2017

Regex in php- catching 9 types of numbers out of a string

I just started coding and have a little problem with regex in PHP.

I am trying to catch the following number types out of a string.

000 000 00 00 -
000 000 00 0 -
000 000 00 -
000.000.00.00 -
000.000.00.0 -
000.000.00 -
0000000000 -
000000000 -
00000000 -

And of course the 0 stands for a number between 0-9.

This is the pattern I've tried:

$pattern = "/\d{3}[. ]\d{3}[. ]\d{2}[. ]?\d{1-2}?/";

Something is wrong here, but I don't understand what?

Can you help me?

Aucun commentaire:

Enregistrer un commentaire