🔍 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.

182 lines
6.4KB

  1. [{
  2. "name":"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":"Time in 24-hour format",
  9. "regex":"^([01]?[0-9]|2[0-3]):[0-5][0-9]$",
  10. "description": "Match times in 24 hour format",
  11. "tags":"date,time"
  12. },
  13. {
  14. "name":"Date and time in ISO-8601 format",
  15. "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)))))$",
  16. "description": "Will match a valid date and times in the ISO-8601 format, excludes durations.",
  17. "tags": "date,time"
  18. },
  19. {
  20. "name":"HTML tags",
  21. "regex":"^<([a-z1-6]+)([^<]+)*(?:>(.*)<\\\\/\\\\1>| *\\\\/>)$",
  22. "description":"Match opening and closing HTML tags with content between",
  23. "tags":"markup,xml,html"
  24. },
  25. {
  26. "name":"Username",
  27. "regex":"^[a-zA-Z0-9_-]{3,16}$",
  28. "description":"A string between 3 and 16 characters, allowing alphanumeric characters and hyphens and underscores",
  29. "tags":"username,validation"
  30. },
  31. {
  32. "name":"Hex Color Value",
  33. "regex":"^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$",
  34. "description":"RGB hex colors",
  35. "tags":"hex,color"
  36. },
  37. {
  38. "name":"URL Slug",
  39. "regex":"^[a-z0-9-]+$",
  40. "description":"Match valid URL slugs",
  41. "tags":"URL"
  42. },
  43. {
  44. "name":"Email",
  45. "regex":"^.+@.+$",
  46. "description":"Verify that there is an @ symbol with something before it",
  47. "tags":"email,validation"
  48. },
  49. {
  50. "name":"SRC of image tag",
  51. "regex":"^<\\s*img[^>]+src\\s*=\\s*([\"'])(.*?)\\1[^>]*>$",
  52. "description":"Match the src attribute of an HTML image tag",
  53. "tags":"html,tag,image"
  54. },
  55. {
  56. "name":"URL",
  57. "regex":"^((https?|ftp|file):\\/\\/)?([\\da-z\\.-]+)\\.([a-z\\.]{2,6})([\\/\\w \\.-]*)*\\/?$",
  58. "description":"Match URL with optional protocol",
  59. "tags":"url,address,http"
  60. },
  61. {
  62. "name":"IPv4 Address",
  63. "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]?)$",
  64. "description":"Match IP v4 addresses",
  65. "tags":"tcpip,internet,address"
  66. },
  67. {
  68. "name":"IPv6 Address",
  69. "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]))$",
  70. "description": "Match IP v6 addresses",
  71. "tags":"tcpip,internet,address"
  72. },
  73. {
  74. "name":"JWT",
  75. "regex":"^[A-Za-z0-9-_=]+\\.[A-Za-z0-9-_=]+\\.?[A-Za-z0-9-_.+/=]*$",
  76. "description": "JSON Web Token (encoded)",
  77. "tags":"www"
  78. },
  79. {
  80. "name":"Positive Integer",
  81. "regex":"^\\d+$",
  82. "description":"Match whole numbers above zero",
  83. "tags":"number"
  84. },
  85. {
  86. "name":"Negative Integer",
  87. "regex":"^-\\d+$",
  88. "description":"Match whole numbers below zero",
  89. "tags":"number"
  90. },
  91. {
  92. "name":"Integer",
  93. "regex":"^-?\\d+$",
  94. "description":"Match whole numbers, above or below zero",
  95. "tags":"number"
  96. },
  97. {
  98. "name":"Positive number",
  99. "regex":"^\\d*\\.?\\d+$",
  100. "description":"Match integers or floats that are positive",
  101. "tags":"float"
  102. },
  103. {
  104. "name":"Negative number",
  105. "regex":"^-\\d*\\.?\\d+$",
  106. "description":"Match integers or floats that are negative",
  107. "tags":"float"
  108. },
  109. {
  110. "name":"Positive or negative number",
  111. "regex":"^-?\\d*\\.?\\d+$",
  112. "description":"Match integers or floats that are positive or negative",
  113. "tags":"float"
  114. },
  115. {
  116. "name":"Phone number",
  117. "regex":"^\\+?(\\d.*){3,}$",
  118. "description":"Match phone numbers at least 3 digits long",
  119. "tags":"validation"
  120. },
  121. {
  122. "name":"New line",
  123. "regex":"[\\r\\n]|$",
  124. "description":"Match new lines within text",
  125. "tags":"text"
  126. },
  127. {
  128. "name":"ID of Youtube video",
  129. "regex":"https?:\\/\\/(?:youtu\\.be\\/|(?:[a-z]{2,3}\\.)?youtube\\.com\\/watch(?:\\?|#\\!)v=)([\\w-]{11}).*/gi",
  130. "description":"Match the ID of a youtube video URL",
  131. "tags":"video,youtube,url"
  132. },
  133. {
  134. "name":"ID of Youtube Channel",
  135. "regex":"https?:\\/\\/(www\\.)?youtube.com\\/channel\\/UC([-_a-z0-9]{22})/i",
  136. "description":"Match the ID of a youtube channel URL",
  137. "tags":"channel,youtube,url"
  138. },
  139. {
  140. "name":"CSS comment",
  141. "regex":"\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\/",
  142. "description":"Match standard CSS comments",
  143. "tags":"css,comment,code"
  144. },
  145. {
  146. "name":"Wordpress shortcodes",
  147. "regex":"^\\[([a-z-_0-9]+)([^\\[]+)*(?:\\](.*)\\[\\/\\1\\]|\\s+\\/\\])$",
  148. "description":"Matches opening and closing shortcode tags with content in-between them.",
  149. "tags":"wordpress,shortcodes,markup"
  150. },
  151. {
  152. "name":"U.S./Canadian ZIP/Postal Code",
  153. "regex":"(^\\d{5}(-\\d{4})?$)|(^[ABCEGHJKLMNPRSTVXY]{1}\\d{1}[A-Z]{1} *\\d{1}[A-Z]{1}\\d{1}$)",
  154. "description":"Matches US ZIP, ZIP+4, and Canadian Postal Codes",
  155. "tags":"address, postal, zip"
  156. },
  157. {
  158. "name":"UK Postal Code",
  159. "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}))$",
  160. "description":"Matches all UK postcodes",
  161. "tags":"address, postal, zip"
  162. },
  163. {
  164. "name":"Brazilian ZIP/Postal Code",
  165. "regex":"^[0-9]{5}-[0-9]{3}$",
  166. "description":"Matches BR ZIP/Postal Code",
  167. "tags":"address, postal, zip"
  168. },
  169. {
  170. "name":"Morse Code",
  171. "regex":"^[.-]{1,5}(?:[ \\t]+[.-]{1,5})*(?:[ \\t]+[.-]{1,5}(?:[ \\t]+[.-]{1,5})*)*$",
  172. "description":"Matches valid Morse Code",
  173. "tags":"morse, code"
  174. },
  175. {
  176. "name":"Image shortcode",
  177. "regex":"\\[img\\](.*?)\\[\\/img\\]",
  178. "description":"Matches the content in between [img][/img]. Useful for making dynamic WYSIWYG editors",
  179. "tags":"img, shortcode, wysiwyg"
  180. }
  181. ]