All files / src/helpers/regexp regexp.js

100% Statements 20/20
100% Branches 0/0
100% Functions 0/0
100% Lines 20/20

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173          2x                                               2x         2x                                                             2x         2x         2x         2x         2x         2x         2x         2x         2x         2x         2x 2x         2x                                                                   2x         2x         2x             2x
import {digit, whitespace, highSurrogate, lowSurrogate, diacriticalMark, base, generalPunctuationBlock, nonCharacter, dingbatBlock, lowerCaseLetter, upperCaseLetter} from "./const"
 
/**
 * Regular expression to match combining marks
 */
export const REGEXP_COMBINING_MARKS = new RegExp(
    '([' +
    base +
    ']|[' +
    highSurrogate +
    '][' +
    lowSurrogate +
    ']|[' +
    highSurrogate +
    '](?![' +
    lowSurrogate +
    '])|(?:[^' +
    highSurrogate +
    ']|^)[' +
    lowSurrogate +
    '])([' +
    diacriticalMark +
    ']+)',
    'g'
)
 
/**
 * Regular expression to match surrogate pairs
 */
export const REGEXP_SURROGATE_PAIRS = new RegExp('([' + highSurrogate + '])([' + lowSurrogate + '])', 'g')
 
/**
 * Regular expression to match a unicode character
 */
export const REGEXP_UNICODE_CHARACTER = new RegExp(
    '((?:[' +
    base +
    ']|[' +
    highSurrogate +
    '][' +
    lowSurrogate +
    ']|[' +
    highSurrogate +
    '](?![' +
    lowSurrogate +
    '])|(?:[^' +
    highSurrogate +
    ']|^)[' +
    lowSurrogate +
    '])(?:[' +
    diacriticalMark +
    ']+))|\
([' +
    highSurrogate +
    '][' +
    lowSurrogate +
    '])|\
([\\n\\r\\u2028\\u2029])|\
(.)',
    'g'
)
 
/**
 * Regular expression to match whitespaces
 */
export const REGEXP_WHITESPACE = new RegExp('[' + whitespace + ']')
 
/**
 * Regular expression to match whitespaces from the left side
 */
export const REGEXP_TRIM_LEFT = new RegExp('^[' + whitespace + ']+')
 
/**
 * Regular expression to match whitespaces from the right side
 */
export const REGEXP_TRIM_RIGHT = new RegExp('[' + whitespace + ']+$')
 
/**
 * Regular expression to match digit characters
 */
export const REGEXP_DIGIT = new RegExp('^' + digit + '+$')
 
/**
 * Regular expression to match regular expression special characters
 */
export const REGEXP_SPECIAL_CHARACTERS = /[-[\]{}()*+!<=:?./\\^$|#,]/g
 
/**
 * Regular expression to match not latin characters
 */
export const REGEXP_NON_LATIN = /[^A-Za-z0-9]/g
 
/**
 * Regular expression to match HTML special characters.
 */
export const REGEXP_HTML_SPECIAL_CHARACTERS = /[<>&"'`]/g
 
/**
 * Regular expression to match sprintf format string
 */
export const REGEXP_CONVERSION_SPECIFICATION = /(%{1,2})(?:(\d+)\$)?(\+)?([ 0]|'.{1})?(-)?(\d+)?(?:\.(\d+))?([bcdiouxXeEfgGs])?/g
 
/**
 * Regular expression to match trailing zeros in a number
 */
export const REGEXP_TRAILING_ZEROS = /\.?0+$/g
 
/**
 * Regular expression to match flags from a regular expression.
 */
export const REGEXP_FLAGS = /[gimuy]*$/
 
/**
 * Regular expression to match a list of tags.
 */
export const REGEXP_TAG_LIST = /<([A-Za-z0-9]+)>/g
export const REGEXP_TAGS = /(<([^>]+)>)/ig
 
/**
 * Regular expression to match Unicode words
 */
export const REGEXP_WORD = new RegExp(
    '(?:[' +
    upperCaseLetter +
    '][' +
    diacriticalMark +
    ']*)?(?:[' +
    lowerCaseLetter +
    '][' +
    diacriticalMark +
    ']*)+|\
(?:[' +
    upperCaseLetter +
    '][' +
    diacriticalMark +
    ']*)+(?![' +
    lowerCaseLetter +
    '])|\
[' +
    digit +
    ']+|\
[' +
    dingbatBlock +
    ']|\
[^' +
    nonCharacter +
    generalPunctuationBlock +
    whitespace +
    ']+',
    'g'
)
 
/**
 * Regular expression to match words from Basic Latin and Latin-1 Supplement blocks
 */
export const REGEXP_LATIN_WORD = /[A-Z\xC0-\xD6\xD8-\xDE]?[a-z\xDF-\xF6\xF8-\xFF]+|[A-Z\xC0-\xD6\xD8-\xDE]+(?![a-z\xDF-\xF6\xF8-\xFF])|\d+/g
 
/**
 * Regular expression to match alpha characters
 */
export const REGEXP_ALPHA = new RegExp('^(?:[' + lowerCaseLetter + upperCaseLetter + '][' + diacriticalMark + ']*)+$')
 
/**
 * Regular expression to match alpha and digit characters
 */
export const REGEXP_ALPHA_DIGIT = new RegExp(
    '^((?:[' + lowerCaseLetter + upperCaseLetter + '][' + diacriticalMark + ']*)|[' + digit + '])+$'
)
 
/**
 * Regular expression to match Extended ASCII characters, i.e. the first 255
 */
export const REGEXP_EXTENDED_ASCII = /^[\x01-\xFF]*$/