Regex for "tel" URIs


/ Published in: Regular Expression
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /****************************************
  2. Regex for "tel" URIs
  3. (Created for JavaScript)
  4.  
  5. See RFC 3966 http://tools.ietf.org/html/rfc3966#section-3
  6.  
  7. Matching examples:
  8.  
  9. tel:+1(800)555-1212
  10. tel:+18005551212,+18005553434;ext=123
  11. tel:911;phone-context=+1
  12. tel:123;phone-context=example.com
  13. /****************************************/
  14.  
  15. ^tel:((?:\+[\d().-]*\d[\d().-]*|[0-9A-F*#().-]*[0-9A-F*#][0-9A-F*#().-]*(?:;[a-z\d-]+(?:=(?:[a-z\d\[\]\/:&+$_!~*'().-]|%[\dA-F]{2})+)?)*;phone-context=(?:\+[\d().-]*\d[\d().-]*|(?:[a-z0-9]\.|[a-z0-9][a-z0-9-]*[a-z0-9]\.)*(?:[a-z]|[a-z][a-z0-9-]*[a-z0-9])))(?:;[a-z\d-]+(?:=(?:[a-z\d\[\]\/:&+$_!~*'().-]|%[\dA-F]{2})+)?)*(?:,(?:\+[\d().-]*\d[\d().-]*|[0-9A-F*#().-]*[0-9A-F*#][0-9A-F*#().-]*(?:;[a-z\d-]+(?:=(?:[a-z\d\[\]\/:&+$_!~*'().-]|%[\dA-F]{2})+)?)*;phone-context=\+[\d().-]*\d[\d().-]*)(?:;[a-z\d-]+(?:=(?:[a-z\d\[\]\/:&+$_!~*'().-]|%[\dA-F]{2})+)?)*)*)$

URL: http://tools.ietf.org/html/rfc3966#section-3

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.