Regex Pattern for Philippine Phone Number -


there 2 types of phone number in philippines.

first type = start 09 followed 9 numbers. did this. pattern this.

^(09)\\d{9} 

and working.

second type = start +639 followed 9 numbers. example +6391571825. can't identify pattern because has special character. pattern this?

just escape special character , place in alternation as

^(09|\+639)\d{9}$ 
  • (09|\+639) alternation matches either 09 or +639

  • $ anchors regex @ end of string. ensures no more digits can appear after 9 characters.

regex demo


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -