Posted By

wizard04 on 01/26/09


Tagged

regex javascript phone uri telephone tel


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

LeeRJohnson
Tyster


Regex for "tel" URIs


 / Published in: Regular Expression
 

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

  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})+)?)*)*)$

Report this snippet  

You need to login to post a comment.