Regex for mobile number validation In my country (South Africa) mobile numbers have 10 digits and always start with a "0" (e.g. 0821231231).

But they can also have the international dialing code ("+27") replacing the "0" (e.g. +27821231231).

I have this regex:

((\+27)|(^(?!\+)(0)))\d{9}


Is there any way that this can be improved upon?
I guess it depends a bit on what kind of input text you have but if you wanna do exact match per line

^(\+27|0)\d{9}$


would work well. If you wanna be liberal what comes before and after then

.*(\+27|0)\d{9}.*


I agree with st88 that negative lookahead makes it confusing. Better to provide your expectation before and after the main pattern (like above)