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

java - Solr query version issue: Invalid version or the data in not in 'javabin' format -

Hard vs. Soft Water: What's The Difference?

The Ten Most Livable Cities In The World