1 changed files with 18 additions and 1 deletions
@ -1 +1,18 @@ |
|||
export default /(([^\s,]*\.(com|ninja))|(?:[0-9]{1,3}\.){3}[0-9]{1,3})(:[0-9]+)?(\/([^\s,.]*)?)?(?=[\s,.]|$)/g; |
|||
// Reusables
|
|||
const escapeChar = `\\`; |
|||
const notWhitespaceOrComma = `[^${escapeChar}s,]`; |
|||
const notWhitespaceCommaOrDot = `[^${escapeChar}s,.]`; |
|||
const WhitespaceCommaDotOrEndOfLine = `[${escapeChar}s,.]|$`; |
|||
const number = `[0-9]`; |
|||
|
|||
// Sections
|
|||
const hostname = `(${notWhitespaceOrComma}*${escapeChar}.(com|ninja))`; |
|||
const ip = `(${number}{1,3}${escapeChar}.){3}${number}{1,3}`; |
|||
const optionalPortNumber = `(:${number}+)?`; |
|||
const optionalSlash = `(${escapeChar}/(${notWhitespaceCommaOrDot}*)?)?`; |
|||
const endsWithButDontMatch = `(?=${WhitespaceCommaDotOrEndOfLine})`; |
|||
|
|||
// Build
|
|||
const regex = `(${hostname}|${ip})${optionalPortNumber}${optionalSlash}${endsWithButDontMatch}`; |
|||
|
|||
export default new RegExp(regex, 'gi'); |
|||
|
Loading…
Reference in new issue