I want to put this regexs into one regex, but dont now how:
/^([0-9]{2,4})\-([0-9]{6,7})$/
/^\*([0-9]{4})$/
so the string can get XX(XX)-XXXXXX(X) or *XXXX
Thanks.
to merge two regular expressions A
and B
, do:
/(A|B)/
This may change the order of one set of capturing parentheses. Also note that parentheses may not be needed, e.g. A|B
may work in your simple case.
In other languages which support regular expressions with named captures, you can use those.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With