samedi 29 novembre 2014

Improve Regex for match valid values


I need some help building this three RegEx since I'm missing something and some values are not matched.




  • First test here]: ^(?:(?:00|\+)58|0)(?:2(?:12|4[0-9]|5[1-9]|6[0-9]|7[0-8]|8[1-35-8]|9[1-5]|3[45789]))\d{7}$


    Input (valid values pattern): 02121234567, +582121234567, 2121234567, (212)123.41.25, (212)-123.41.25 Input (invalid values pattern): (9212)123.41.25, (21200)-123.41.25


    In this case the RegEx build I made works for this patterns: 02121234567, +582121234567 but not for the rest



    • Second test here]: ^(?:(?:00|\+)58)(?:4(?:1[246]|2[46]))\d{7}$


    Input (valid values pattern): 04241234567, +584241234567, 4241234567, (424)123.41.25, 04141234567, +584141234567, 4141234567, (414)123.41.25, 04121234567, +584121234567, 4121234567, (412)123.41.25 Input (invalid values pattern): (123)123.41.25, (4246)123.41.25


    In this case the RegEx build I made works for this patterns: +584241234567 but not for the rest



    • Third: ^\+?(?:\(\d{1,4}\)|\d{1,4})?\s*[\d\s.]{6,14}$


    Input (valid values pattern): +584242511330, 00584242511330, 4242511330, (424)251.13.30 Input (invalid values pattern): 123 456 213, +12 345 678, +48 315 182 12 63, (4567)8457435


    In this case the RegEx build I made works but allow also invalid patterns




Can I get some help here?





Aucun commentaire:

Enregistrer un commentaire