regex.rst 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. ####################
  2. Regular Expressions
  3. ####################
  4. * ^ Start of the string
  5. * $ End of the string
  6. * ? optional example 1? makes the 1 optional
  7. * \\d{10} 10 digits
  8. * ( and ) gets matching digits inside brackets sets a $1 and second set of brackets creates $2
  9. * ^\\+?1?(\\d{10})$ 10 to 11 digits and e164 format sets $1 to 10 digits
  10. * [0-9] Any number between 0 to 9
  11. * [2-9] Any number between 2 to 9
  12. * \| The pipe works like an OR. Example ^101$|^102$ matches 101 or 102
  13. * ^9(\\d{10})$ This strips off the 9 and the $1 value is the remaining 10 digits
  14. **Dialplan Expression**
  15. * **Two digits:** ^(\\d{2})$
  16. * **Three digits:** ^(\\d{3})$
  17. * **Four digits:** ^(\\d{4})$
  18. * **FIve digits:** ^(\\d{5})$
  19. * **Six digits:** ^(\\d{6})$
  20. * **Seven digits(Local Calling):** ^(\\d{7})$
  21. * **Eight digits:** ^(\\d{8})$
  22. * **Nine digits:** ^(\\d{9})$
  23. * **Ten digits(Long Distance):** ^(\\d{10})$
  24. * **Eleven digits(Long Distance with a 1):** ^\\+?(\\d{11})$
  25. * **North America:** ^\\+?1?(\\d{10})$
  26. * **North America International:** ^(011\\d{9,17})$
  27. * **Caribbean:** ^(?:\+1|1)((?:684|264|268|242|246|441|284|345|767|809|829|849|473|876|664|670|787|939|869|758|784|721|868|649)\\d{7})$
  28. * **Europe International:** ^(00\\d{9,17})$
  29. * **International:** ^(\\d{12,20})$
  30. * **311 Information:** ^(311)$
  31. * **711 TTY:** ^(711)$
  32. * **911 Emergency:** ^(911)$
  33. * **Toll Free:** ^1?(8(00|55|66|77|88)[2-9]\\d{6})$
  34. * **INUM:** ^0118835100\\d{8}$
  35. * **Dial 9 then Two digits:** ^9(\\d{2})$
  36. * **Dial 9 then Three digits:** ^9(\\d{3})$
  37. * **Dial 9 then Four digits:** ^9(\\d{4})$
  38. * **Dial 9 then Five digits:** ^9(\\d{5})$
  39. * **Dial 9 then Six digits:** ^9(\\d{6})$
  40. * **Dial 9 then Seven digits:** ^9(\\d{7})$
  41. * **Dial 9 then Eight digits:** ^9(\\d{8})$
  42. * **Dial 9 then Nine digits:** ^9(\\d{9})$
  43. * **Dial 9 then Ten digits:** ^9(\\d{10})$
  44. * **Dial 9 then Eleven digits:** ^9(\\d{11})$
  45. * **Dial 9 then International:** ^9(\\d{12,20})$
  46. **Links**
  47. * https://regex101.com/
  48. * https://regex101.com/r/QmOZiH/3/
  49. * https://regexr.com/
  50. * https://extendsclass.com/regex-tester.html
  51. * https://softwium.com/regex-explainer/