voca
Version:
The ultimate JavaScript string library
160 lines (140 loc) • 4.03 kB
JavaScript
/**
* A regular expression string matching digits
*
* @type {string}
* @ignore
*/
var digit = '\\d';
/**
* A regular expression string matching whitespace
*
* @type {string}
* @ignore
*/
var whitespace = '\\s\\uFEFF\\xA0';
/**
* A regular expression string matching high surrogate
*
* @type {string}
* @ignore
*/
var highSurrogate = '\\uD800-\\uDBFF';
/**
* A regular expression string matching low surrogate
*
* @type {string}
* @ignore
*/
var lowSurrogate = '\\uDC00-\\uDFFF';
/**
* A regular expression string matching diacritical mark
*
* @type {string}
* @ignore
*/
var diacriticalMark = '\\u0300-\\u036F\\u1AB0-\\u1AFF\\u1DC0-\\u1DFF\\u20D0-\\u20FF\\uFE20-\\uFE2F';
/**
* A regular expression to match the base character for a combining mark
*
* @type {string}
* @ignore
*/
var base = '\\0-\\u02FF\\u0370-\\u1AAF\\u1B00-\\u1DBF\\u1E00-\\u20CF\\u2100-\\uD7FF\\uE000-\\uFE1F\\uFE30-\\uFFFF';
/**
* Regular expression to match combining marks
*
* @see http://unicode.org/faq/char_combmark.html
* @type {RegExp}
* @ignore
*/
var REGEXP_COMBINING_MARKS = new RegExp('([' + base + ']|[' + highSurrogate + '][' + lowSurrogate + ']|[' + highSurrogate + '](?![' + lowSurrogate + '])|(?:[^' + highSurrogate + ']|^)[' + lowSurrogate + '])([' + diacriticalMark + ']+)', 'g');
/**
* Regular expression to match surrogate pairs
*
* @see http://www.unicode.org/faq/utf_bom.html#utf16-2
* @type {RegExp}
* @ignore
*/
var REGEXP_SURROGATE_PAIRS = new RegExp('([' + highSurrogate + '])([' + lowSurrogate + '])', 'g');
/**
* Regular expression to match a unicode character
*
* @type {RegExp}
* @ignore
*/
var 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
*
* @type {RegExp}
* @ignore
*/
var REGEXP_WHITESPACE = new RegExp('[' + whitespace + ']');
/**
* Regular expression to match whitespaces from the left side
*
* @type {RegExp}
* @ignore
*/
var REGEXP_TRIM_LEFT = new RegExp('^[' + whitespace + ']+');
/**
* Regular expression to match whitespaces from the right side
*
* @type {RegExp}
* @ignore
*/
var REGEXP_TRIM_RIGHT = new RegExp('[' + whitespace + ']+$');
/**
* Regular expression to match digit characters
*
* @type {RegExp}
* @ignore
*/
var REGEXP_DIGIT = new RegExp('^' + digit + '+$');
/**
* Regular expression to match regular expression special characters
*
* @type {RegExp}
* @ignore
*/
var REGEXP_SPECIAL_CHARACTERS = /[-[\]{}()*+!<=:?./\\^$|#,]/g;
/**
* Regular expression to match not latin characters
*
* @type {RegExp}
* @ignore
*/
var REGEXP_NON_LATIN = /[^A-Za-z0-9]/g;
/**
* Regular expression to match HTML special characters.
*
* @type {RegExp}
* @ignore
*/
var REGEXP_HTML_SPECIAL_CHARACTERS = /[<>&"'`]/g;
/**
* Regular expression to match sprintf format string
*
* @type {RegExp}
* @ignore
*/
var REGEXP_CONVERSION_SPECIFICATION = /(%{1,2})(?:(\d+)\$)?(\+)?([ 0]|'.{1})?(-)?(\d+)?(?:\.(\d+))?([bcdiouxXeEfgGs])?/g;
/**
* Regular expression to match trailing zeros in a number
*
* @type {RegExp}
* @ignore
*/
var REGEXP_TRAILING_ZEROS = /\.?0+$/g;
/**
* Regular expression to match a list of tags.
*
* @see https://html.spec.whatwg.org/multipage/syntax.html#syntax-tag-name
* @type {RegExp}
* @ignore
*/
var REGEXP_TAG_LIST = /<([A-Za-z0-9]+)>/g;
export { REGEXP_UNICODE_CHARACTER as R, digit as a, REGEXP_COMBINING_MARKS as b, REGEXP_SURROGATE_PAIRS as c, diacriticalMark as d, REGEXP_HTML_SPECIAL_CHARACTERS as e, REGEXP_SPECIAL_CHARACTERS as f, REGEXP_TRAILING_ZEROS as g, REGEXP_CONVERSION_SPECIFICATION as h, REGEXP_NON_LATIN as i, REGEXP_TRIM_LEFT as j, REGEXP_TRIM_RIGHT as k, REGEXP_DIGIT as l, REGEXP_TAG_LIST as m, REGEXP_WHITESPACE as n, whitespace as w };