Просмотр исходного кода

Clean up regex template patterns for R

tags/v0.2.0
Garrick Aden-Buie 8 лет назад
Родитель
Сommit
549d1c6676
1 измененных файлов: 43 добавлений и 31 удалений
  1. +43
    -31
      inst/extdata/patterns.json

+ 43
- 31
inst/extdata/patterns.json Просмотреть файл

@@ -1,150 +1,162 @@
[{
"name":"Date in format dd/mm/yyyy",
"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])?$",
"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])?",
"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).",
"tags":"date,time"
},
{
"name":"Date in format mm/dd/yyyy",
"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])))?",
"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).",
"tags":"date,time"
},
{
"name":"Time in 24-hour format",
"regex":"^([01]?[0-9]|2[0-3]):[0-5][0-9]$",
"regex":"([01]?[0-9]|2[0-3]):([0-5][0-9]):?([0-5][0-9])?",
"description": "Match times in 24 hour format",
"tags":"date,time"
},
{
"name":"Date and time in ISO-8601 format",
"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)))))$",
"description": "Will match a valid date and times in the ISO-8601 format, excludes durations.",
"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)))))",
"description": "Will match a valid date and times in the ISO-8601 format, excludes durations. Requires perl style.",
"tags": "date,time"
},
{
"name":"HTML tags",
"regex":"^<([a-z1-6]+)([^<]+)*(?:>(.*)<\\\\/\\\\1>| *\\\\/>)$",
"regex":"<([a-z1-6]+)([^<]+)*(?:>(.*)</\\1>| */>)",
"description":"Match opening and closing HTML tags with content between",
"tags":"markup,xml,html"
},
{
"name":"Username",
"regex":"^[a-zA-Z0-9_-]{3,16}$",
"regex":"[a-zA-Z0-9_-]{3,16}",
"description":"A string between 3 and 16 characters, allowing alphanumeric characters and hyphens and underscores",
"tags":"username,validation"
},
{
"name":"Hex Color Value",
"regex":"^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$",
"regex":"#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})\\b",
"description":"RGB hex colors",
"tags":"hex,color"
},
{
"name":"URL Slug",
"regex":"^[a-z0-9-]+$",
"regex":"[[:alnum:]-]+",
"description":"Match valid URL slugs",
"tags":"URL"
},
{
"name":"Email",
"regex":"^.+@.+$",
"description":"Verify that there is an @ symbol with something before it",
"regex":"([[:alnum:]_.-]+)@([[:alnum:].-]+)\\.([[:alpha:].]{2,6})",
"description":"Simple (but imperfect) email validation",
"tags":"email,validation"
},
{
"name":"SRC of image tag",
"regex":"^<\\s*img[^>]+src\\s*=\\s*([\"'])(.*?)\\1[^>]*>$",
"regex":"<\\s*img[^>]+src\\s*=\\s*([\"'])(.*?)\\1[^>]*>",
"description":"Match the src attribute of an HTML image tag",
"tags":"html,tag,image"
},
{
"name":"URL",
"regex":"^((https?|ftp|file):\\/\\/)?([\\da-z\\.-]+)\\.([a-z\\.]{2,6})([\\/\\w \\.-]*)*\\/?$",
"regex":"((https?|ftp|file)://)?([[:alnum:].-]+)\\.([a-zA-Z.]{2,6})([/[[:alpha:].-]*)*/?",
"description":"Match URL with optional protocol",
"tags":"url,address,http"
},
{
"name":"IPv4 Address",
"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]?)$",
"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]?)",
"description":"Match IP v4 addresses",
"tags":"tcpip,internet,address"
},
{
"name":"IPv6 Address",
"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]))$",
"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]))",
"description": "Match IP v6 addresses",
"tags":"tcpip,internet,address"
},
{
"name":"JWT",
"regex":"^[A-Za-z0-9-_=]+\\.[A-Za-z0-9-_=]+\\.?[A-Za-z0-9-_.+/=]*$",
"regex":"[A-Za-z0-9-_=]+\\.[A-Za-z0-9-_=]+\\.?[A-Za-z0-9-_.+/=]*",
"description": "JSON Web Token (encoded)",
"tags":"www"
},
{
"name":"Positive Integer",
"regex":"^\\d+$",
"regex":"\\d+",
"description":"Match whole numbers above zero",
"tags":"number"
},
{
"name":"Negative Integer",
"regex":"^-\\d+$",
"regex":"-\\d+",
"description":"Match whole numbers below zero",
"tags":"number"
},
{
"name":"Integer",
"regex":"^-?\\d+$",
"regex":"-?\\d+",
"description":"Match whole numbers, above or below zero",
"tags":"number"
},
{
"name":"Positive number",
"regex":"^\\d*\\.?\\d+$",
"regex":"\\d*\\.?\\d+",
"description":"Match integers or floats that are positive",
"tags":"float"
},
{
"name":"Negative number",
"regex":"^-\\d*\\.?\\d+$",
"regex":"-\\d*\\.?\\d+",
"description":"Match integers or floats that are negative",
"tags":"float"
},
{
"name":"Positive or negative number",
"regex":"^-?\\d*\\.?\\d+$",
"regex":"-?\\d*\\.?\\d+",
"description":"Match integers or floats that are positive or negative",
"tags":"float"
},
{
"name":"Phone number",
"regex":"^\\+?(\\d.*){3,}$",
"name":"Phone number (general)",
"regex":"\\+?(\\d.*){3,}",
"description":"Match phone numbers at least 3 digits long",
"tags":"validation"
},
{
"name":"Phone number (US)",
"regex":"(?:1)?[ .-]?(?:\\(?([2-9][0-9]{2})\\)?[ .-]?)?(?:(([2-9][0-9]{2})[ .-]?([0-9]{4}))|([0-9]{3}[ .-]?[0-9]{4}))",
"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.",
"tags":"validation"
},
{
"name":"New line",
"regex":"[\\r\\n]|$",
"regex":"[\\r\\n]",
"description":"Match new lines within text",
"tags":"text"
},
{
"name":"ID of Youtube video",
"regex":"https?:\\/\\/(?:youtu\\.be\\/|(?:[a-z]{2,3}\\.)?youtube\\.com\\/watch(?:\\?|#\\!)v=)([\\w-]{11}).*/gi",
"regex":"https?://(?:youtu\\.be/|(?:[a-z]{2,3}\\.)?youtube\\.com/watch(?:\\?|#!)v=)([[:alnum:]-]{11}).*",
"description":"Match the ID of a youtube video URL",
"tags":"video,youtube,url"
},
{
"name":"ID of Youtube Channel",
"regex":"https?:\\/\\/(www\\.)?youtube.com\\/channel\\/UC([-_a-z0-9]{22})/i",
"regex":"https?://(www\\.)?youtube.com/channel/UC([-_a-z0-9]{22})/i",
"description":"Match the ID of a youtube channel URL",
"tags":"channel,youtube,url"
},
{
"name":"CSS comment",
"regex":"\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\/",
"regex":"/\\*[^*]*\\*+([^/*][^*]*\\*+)*/",
"description":"Match standard CSS comments",
"tags":"css,comment,code"
},
{
"name":"Wordpress shortcodes",
"regex":"^\\[([a-z-_0-9]+)([^\\[]+)*(?:\\](.*)\\[\\/\\1\\]|\\s+\\/\\])$",
"regex":"\\[([a-z-_0-9]+)([^\\[]+)*(?:\\](.*)\\[/\\1\\]|\\s+/\\])",
"description":"Matches opening and closing shortcode tags with content in-between them.",
"tags":"wordpress,shortcodes,markup"
},
@@ -156,19 +168,19 @@
},
{
"name":"UK Postal Code",
"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}))$",
"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}))",
"description":"Matches all UK postcodes",
"tags":"address, postal, zip"
},
{
"name":"Brazilian ZIP/Postal Code",
"regex":"^[0-9]{5}-[0-9]{3}$",
"regex":"[0-9]{5}-[0-9]{3}",
"description":"Matches BR ZIP/Postal Code",
"tags":"address, postal, zip"
},
{
"name":"Morse Code",
"regex":"^[.-]{1,5}(?:[ \\t]+[.-]{1,5})*(?:[ \\t]+[.-]{1,5}(?:[ \\t]+[.-]{1,5})*)*$",
"regex":"[.-]{1,5}(?:[ \\t]+[.-]{1,5})*(?:[ \\t]+[.-]{1,5}(?:[ \\t]+[.-]{1,5})*)*",
"description":"Matches valid Morse Code",
"tags":"morse, code"
},

Загрузка…
Отмена
Сохранить