\d{3}-\d{4}
This one matches something like 123-4567
So I change it to ^(?!(\d{3}-\d{4})). But it doesn’t match anything.
I got a list of phone numbers like
123-4567
NOW-4-WAX
12 345 67 89
I would like to match anything except the format xxx-xxxx where x is a digit.
>Solution :
If you add .* to the end of your regex, it should match any line that does not start with a phone number in the 123-4567 format.
Demo on RegExr: ^(?!(\d{3}-\d{4})).*$
It’s worth noting that if you have anything in your input file that is not a phone number at all, this will match those too.