🔍 An RStudio addin slash regex utility belt
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

194 lines
7.2KB

  1. [{
  2. "name":"Date/Time, Date in format dd/mm/yyyy",
  3. "regex":"(0?[1-9]|[12][0-9]|3[01])([ /-])(0?[1-9]|1[012])\\2([0-9][0-9][0-9][0-9])(([ -])([0-1]?[0-9]|2[0-3]):([0-5]?[0-9]):[0-5]?[0-9])?",
  4. "description":"Will match dates with dashes, slashes or with spaces (e.g. dd-mm-yyyy dd/mm/yyyy dd mm yyyy), and optional time separated by a space or a dash (e.g. dd-mm-yyyy-hh:mm:ss or dd/mm/yyyy hh:mm:ss).",
  5. "tags":"date,time"
  6. },
  7. {
  8. "name":"Date/Time, Date in format mm/dd/yyyy",
  9. "regex":"(0?[1-9]|1[012])([ /-])(0?[1-9]|[12][0-9]|3[01])\\2([0-9][0-9][0-9][0-9])(([ -])([0-1]?[0-9]|2[0-3]):([0-5]?[0-9])(?::([0-5]?[0-9])))?",
  10. "description":"Will match dates with dashes, slashes or with spaces (e.g. mm-dd-yyyy mm/dd/yyyy mm dd yyyy), and optional time separated by a space or a dash (e.g. mm-dd-yyyy-hh:mm:ss or mm/dd/yyyy hh:mm:ss).",
  11. "tags":"date,time"
  12. },
  13. {
  14. "name":"Date/Time, Time in 24-hour format",
  15. "regex":"([01]?[0-9]|2[0-3]):([0-5][0-9]):?([0-5][0-9])?",
  16. "description": "Match times in 24 hour format",
  17. "tags":"date,time"
  18. },
  19. {
  20. "name":"Date/Time, ISO-8601 format",
  21. "regex":"(?![+-]?\\d{4,5}-?(?:\\d{2}|W\\d{2})T)(?:|(\\d{4}|[+-]\\d{5})-?(?:|(0\\d|1[0-2])(?:|-?([0-2]\\d|3[0-1]))|([0-2]\\d{2}|3[0-5]\\d|36[0-6])|W([0-4]\\d|5[0-3])(?:|-?([1-7])))(?:(?!\\d)|T(?=\\d)))(?:|([01]\\d|2[0-4])(?:|:?([0-5]\\d)(?:|:?([0-5]\\d)(?:|\\.(\\d{3})))(?:|[zZ]|([+-](?:[01]\\d|2[0-4]))(?:|:?([0-5]\\d)))))",
  22. "description": "Will match a valid date and times in the ISO-8601 format, excludes durations. Requires Perl.",
  23. "tags": "date,time"
  24. },
  25. {
  26. "name":"Web, HTML tags",
  27. "regex":"<([a-z1-6]+)([^<]+)*(?:>(.*)</\\1>| */>)",
  28. "description":"Match opening and closing HTML tags with content between",
  29. "tags":"markup,xml,html"
  30. },
  31. {
  32. "name":"Web, Username",
  33. "regex":"[a-zA-Z0-9_-]{3,16}",
  34. "description":"A string between 3 and 16 characters, allowing alphanumeric characters and hyphens and underscores",
  35. "tags":"username,validation"
  36. },
  37. {
  38. "name":"Hex Color Value",
  39. "regex":"#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})\\b",
  40. "description":"RGB hex colors",
  41. "tags":"hex,color"
  42. },
  43. {
  44. "name":"Web, URL Slug",
  45. "regex":"[[:alnum:]-]+",
  46. "description":"Match valid URL slugs",
  47. "tags":"URL"
  48. },
  49. {
  50. "name":"Web, Email",
  51. "regex":"([[:alnum:]_.-]+)@([[:alnum:].-]+)\\.([[:alpha:].]{2,6})",
  52. "description":"Simple (but imperfect) email validation",
  53. "tags":"email,validation"
  54. },
  55. {
  56. "name":"Web, Image Source Path",
  57. "regex":"<\\s*img[^>]+src\\s*=\\s*([\"'])(.*?)\\1[^>]*>",
  58. "description":"Match the src attribute of an HTML image tag",
  59. "tags":"html,tag,image"
  60. },
  61. {
  62. "name":"Web, URL",
  63. "regex":"((https?|ftp|file)://)?([[:alnum:].-]+)\\.([a-zA-Z.]{2,6})([/[[:alpha:].-]*)*/?",
  64. "description":"Match URL with optional protocol",
  65. "tags":"url,address,http"
  66. },
  67. {
  68. "name":"Network, IPv4 Address",
  69. "regex":"(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",
  70. "description":"Match IP v4 addresses",
  71. "tags":"tcpip,internet,address"
  72. },
  73. {
  74. "name":"Network, IPv6 Address",
  75. "regex":"(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))",
  76. "description": "Match IP v6 addresses",
  77. "tags":"tcpip,internet,address"
  78. },
  79. {
  80. "name":"Web, JSON Web Token",
  81. "regex":"[A-Za-z0-9-_=]+\\.[A-Za-z0-9-_=]+\\.?[A-Za-z0-9-_.+/=]*",
  82. "description": "JSON Web Token (encoded)",
  83. "tags":"www"
  84. },
  85. {
  86. "name":"Number, Positive Integer",
  87. "regex":"\\d+",
  88. "description":"Match whole numbers above zero",
  89. "tags":"number"
  90. },
  91. {
  92. "name":"Number, Negative Integer",
  93. "regex":"-\\d+",
  94. "description":"Match whole numbers below zero",
  95. "tags":"number"
  96. },
  97. {
  98. "name":"Number, Integer",
  99. "regex":"-?\\d+",
  100. "description":"Match whole numbers, above or below zero",
  101. "tags":"number"
  102. },
  103. {
  104. "name":"Number, Positive (integer or float)",
  105. "regex":"\\d*\\.?\\d+",
  106. "description":"Match integers or floats that are positive",
  107. "tags":"float"
  108. },
  109. {
  110. "name":"Number, Negative (integer or float)",
  111. "regex":"-\\d*\\.?\\d+",
  112. "description":"Match integers or floats that are negative",
  113. "tags":"float"
  114. },
  115. {
  116. "name":"Number, Integer or Float",
  117. "regex":"-?\\d*\\.?\\d+",
  118. "description":"Match integers or floats that are positive or negative",
  119. "tags":"float"
  120. },
  121. {
  122. "name":"Phone Number, General",
  123. "regex":"\\+?(\\d.*){3,}",
  124. "description":"Match phone numbers at least 3 digits long",
  125. "tags":"validation"
  126. },
  127. {
  128. "name":"Phone Number, US",
  129. "regex":"(?:1)?[ .-]?(?:\\(?([2-9][0-9]{2})\\)?[ .-]?)?(?:(([2-9][0-9]{2})[ .-]?([0-9]{4}))|([0-9]{3}[ .-]?[0-9]{4}))",
  130. "description":"Match US phone number, with or without country or area code. Matches phone numbers like 1-800-234-5678 or 234-5679 or (555) 432-1234.",
  131. "tags":"validation"
  132. },
  133. {
  134. "name":"Whitespace, New line",
  135. "regex":"\\r|\\n",
  136. "description":"Match new lines within text",
  137. "tags":"text"
  138. },
  139. {
  140. "name":"Whitespace",
  141. "regex":"\\s",
  142. "description":"Match whitespace",
  143. "tags":"text"
  144. },
  145. {
  146. "name":"Web, Youtube ID from Video URL",
  147. "regex":"https?://(?:youtu\\.be/|(?:[a-z]{2,3}\\.)?youtube\\.com/watch(?:\\?|#!)v=)([[:alnum:]-]{11}).*",
  148. "description":"Match the ID of a youtube video URL",
  149. "tags":"video,youtube,url"
  150. },
  151. {
  152. "name":"Web, Youtube ID of Channel from URL",
  153. "regex":"https?://(www\\.)?youtube.com/channel/UC([-_a-z0-9]{22})/i",
  154. "description":"Match the ID of a youtube channel URL",
  155. "tags":"channel,youtube,url"
  156. },
  157. {
  158. "name":"Web, CSS comment",
  159. "regex":"/\\*[^*]*\\*+([^/*][^*]*\\*+)*/",
  160. "description":"Match standard CSS comments",
  161. "tags":"css,comment,code"
  162. },
  163. {
  164. "name":"Web, Wordpress shortcodes",
  165. "regex":"\\[([a-z-_0-9]+)([^\\[]+)*(?:\\](.*)\\[/\\1\\]|\\s+/\\])",
  166. "description":"Matches opening and closing shortcode tags with content in-between them.",
  167. "tags":"wordpress,shortcodes,markup"
  168. },
  169. {
  170. "name":"Postal Code, U.S./Canadian ZIP/Postal Code",
  171. "regex":"(^\\d{5}(-\\d{4})?$)|(^[ABCEGHJKLMNPRSTVXY]{1}\\d{1}[A-Z]{1} *\\d{1}[A-Z]{1}\\d{1}$)",
  172. "description":"Matches US ZIP, ZIP+4, and Canadian Postal Codes",
  173. "tags":"address, postal, zip"
  174. },
  175. {
  176. "name":"Postal Code, UK Postal Code",
  177. "regex":"(([gG][iI][rR] {0,}0[aA]{2})|(([aA][sS][cC][nN]|[sS][tT][hH][lL]|[tT][dD][cC][uU]|[bB][bB][nN][dD]|[bB][iI][qQ][qQ]|[fF][iI][qQ][qQ]|[pP][cC][rR][nN]|[sS][iI][qQ][qQ]|[iT][kK][cC][aA]) {0,}1[zZ]{2})|((([a-pr-uwyzA-PR-UWYZ][a-hk-yxA-HK-XY]?[0-9][0-9]?)|(([a-pr-uwyzA-PR-UWYZ][0-9][a-hjkstuwA-HJKSTUW])|([a-pr-uwyzA-PR-UWYZ][a-hk-yA-HK-Y][0-9][abehmnprv-yABEHMNPRV-Y]))) {0,}[0-9][abd-hjlnp-uw-zABD-HJLNP-UW-Z]{2}))",
  178. "description":"Matches all UK postcodes",
  179. "tags":"address, postal, zip"
  180. },
  181. {
  182. "name":"Postal Code, Brazilian ZIP/Postal Code",
  183. "regex":"[0-9]{5}-[0-9]{3}",
  184. "description":"Matches BR ZIP/Postal Code",
  185. "tags":"address, postal, zip"
  186. },
  187. {
  188. "name":"Morse Code",
  189. "regex":"[.-]{1,5}(?:[ \\t]+[.-]{1,5})*(?:[ \\t]+[.-]{1,5}(?:[ \\t]+[.-]{1,5})*)*",
  190. "description":"Matches valid Morse Code",
  191. "tags":"morse, code"
  192. }
  193. ]