Skip to content

Instantly share code, notes, and snippets.

@AmyShackles
Created July 27, 2021 23:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AmyShackles/201f3017344fb462e2e4ca264abea79c to your computer and use it in GitHub Desktop.
Save AmyShackles/201f3017344fb462e2e4ca264abea79c to your computer and use it in GitHub Desktop.
const inputArray = [
{
type: 'start_of_line',
startingIndex: 0,
lastIndex: 0,
group: '^'
},
{
type: 'positive_lookbehind',
group: '(?<=Hello (a(ga)in))',
match: 'Hello (a(ga)in)',
startingIndex: 1,
lastIndex: 20
},
{
type: 'literal',
startingIndex: 5,
lastIndex: 10,
group: 'Hello '
},
{
type: 'capture_group',
group: '(a(ga)in)',
match: 'a(ga)in',
startingIndex: 11,
lastIndex: 19
},
{ type: 'literal', startingIndex: 12, lastIndex: 12, group: 'a' },
{
type: 'capture_group',
group: '(ga)',
match: 'ga',
startingIndex: 13,
lastIndex: 16
},
{ type: 'literal', startingIndex: 14, lastIndex: 15, group: 'ga' },
{ type: 'literal', startingIndex: 17, lastIndex: 18, group: 'in' },
{
type: 'word_boundary',
startingIndex: 21,
lastIndex: 22,
group: '\\b'
},
{
type: 'capture_group',
group: '(ABC)',
match: 'ABC',
startingIndex: 23,
lastIndex: 27
},
{ type: 'literal', startingIndex: 24, lastIndex: 26, group: 'ABC' },
{
type: 'negated_character_set',
startingIndex: 28,
lastIndex: 33,
group: '[^ack]',
match: 'ack'
},
{ type: 'dotAll', startingIndex: 34, lastIndex: 34, group: '.' },
{
type: 'non_greedy_range_quantifier',
startingIndex: 35,
lastIndex: 38,
group: '{2}?',
min: 2
},
{
type: 'capture_group',
group: '(\\P{Script=Cyrillic} \\p{General_Category=Letter}\\xff \\u{12345})',
match: '\\P{Script=Cyrillic} \\p{General_Category=Letter}\\xff \\u{12345}',
startingIndex: 39,
lastIndex: 101
},
{
type: 'negated_unicode_property_escape',
startingIndex: 40,
lastIndex: 58,
negated_unicode_name: 'Script',
negated_unicode_value: 'Cyrillic',
group: '\\P{Script=Cyrillic}'
},
{ type: 'literal', startingIndex: 59, lastIndex: 59, group: ' ' },
{
type: 'unicode_property_escape',
startingIndex: 60,
lastIndex: 86,
unicode_name: 'General_Category',
unicode_value: 'Letter',
group: '\\p{General_Category=Letter}'
},
{
type: 'hex',
startingIndex: 87,
lastIndex: 90,
group: '\\xff',
match: 'ÿ'
},
{ type: 'literal', startingIndex: 91, lastIndex: 91, group: ' ' },
{
type: 'unicode',
startingIndex: 92,
lastIndex: 100,
group: '\\u{12345}',
match: '𒍅'
},
{
type: 'named_capture_group',
group: '(?<isas>[ai]s)',
match: '[ai]s',
startingIndex: 102,
lastIndex: 115,
name: 'isas'
},
{
type: 'character_set',
startingIndex: 110,
lastIndex: 113,
group: '[ai]',
match: 'ai'
},
{ type: 'literal', startingIndex: 114, lastIndex: 114, group: 's' },
{
type: 'whitespace',
startingIndex: 116,
lastIndex: 117,
group: '\\s'
},
{
type: 'character_set',
startingIndex: 118,
lastIndex: 123,
group: '[easy]',
match: 'easy'
},
{
type: 'greedy_range_quantifier',
startingIndex: 124,
lastIndex: 128,
group: '{1,5}',
min: 1,
max: 5
},
{ type: 'literal', startingIndex: 129, lastIndex: 129, group: ' ' },
{
type: 'unicode_property_escape',
startingIndex: 130,
lastIndex: 145,
unicode_name: 'Script',
unicode_value: 'Latin',
group: '\\p{Script=Latin}'
},
{
type: 'named_backreference',
startingIndex: 146,
lastIndex: 153,
group: '\\k<isas>',
name: 'isas'
},
{
type: 'whitespace',
startingIndex: 154,
lastIndex: 155,
group: '\\s'
},
{
type: 'capture_group',
group: '(123)',
match: '123',
startingIndex: 156,
lastIndex: 160
},
{
type: 'literal',
startingIndex: 157,
lastIndex: 159,
group: '123'
},
{
type: 'numerical_backreference',
startingIndex: 161,
lastIndex: 162,
group: '\\1',
match: '1'
},
{
type: 'numerical_backreference',
startingIndex: 163,
lastIndex: 164,
group: '\\2',
match: '2'
},
{
type: 'greedy_range_quantifier',
startingIndex: 165,
lastIndex: 167,
group: '{3}',
min: 3
},
{
type: 'unicode',
startingIndex: 168,
lastIndex: 173,
group: '\\u1234',
match: 'ሴ'
},
{ type: 'literal', startingIndex: 174, lastIndex: 174, group: ' ' },
{
type: 'character_set',
startingIndex: 175,
lastIndex: 178,
group: '[\\b]',
match: '\\b'
},
{
type: 'backspace',
startingIndex: 176,
lastIndex: 177,
group: '\\b'
},
{
type: 'literal',
startingIndex: 179,
lastIndex: 187,
group: 'sometimes'
},
{
type: 'control_character',
startingIndex: 188,
lastIndex: 190,
group: '\\cM',
match: '\r'
},
{
type: 'non_word_boundary',
startingIndex: 191,
lastIndex: 192,
group: '\\B'
},
{
type: 'positive_lookahead',
group: '(?=Goodbye)',
match: 'Goodbye',
startingIndex: 193,
lastIndex: 203
},
{
type: 'literal',
startingIndex: 196,
lastIndex: 202,
group: 'Goodbye'
},
{
type: 'end_of_line',
startingIndex: 204,
lastIndex: 204,
group: '$'
}
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment