Skip to content

Instantly share code, notes, and snippets.

@joeskeen
Last active November 25, 2022 01:49
Show Gist options
  • Save joeskeen/98c9f0e9d04cd6f32d27015e1b88b589 to your computer and use it in GitHub Desktop.
Save joeskeen/98c9f0e9d04cd6f32d27015e1b88b589 to your computer and use it in GitHub Desktop.
๐Ÿ•Š๏ธ ๐Ÿ–ผ๏ธ ๐Ÿ‡
๐Ÿ–๏ธ๐Ÿ†•isMatch๐Ÿ‘Œ
๐Ÿ–๏ธ๐Ÿ†•matchPosition๐Ÿฌ๐Ÿ”ข
๐Ÿ–๏ธ๐Ÿ†•matchLength๐Ÿฌ๐Ÿ”ข
๐Ÿ†• ๐ŸผisMatch๐Ÿ‘Œ ๐ŸผmatchPosition๐Ÿฌ๐Ÿ”ข ๐ŸผmatchLength๐Ÿฌ๐Ÿ”ข ๐Ÿ‡๐Ÿ‰
๐Ÿ†•โ–ถ๏ธ๐Ÿ“™ ๐Ÿ‡
๐Ÿ‘Ž โžก๏ธ ๐Ÿ–๏ธisMatch
๐Ÿคท โžก๏ธ ๐Ÿ–๏ธmatchPosition
๐Ÿคท โžก๏ธ ๐Ÿ–๏ธmatchLength
๐Ÿ‰
โ“๐Ÿ‘Œ โžก๏ธ ๐Ÿ‘Œ ๐Ÿ‡
โ†ฉ๏ธ isMatch
๐Ÿ‰
โ“๐Ÿฝ โžก๏ธ ๐Ÿฌ๐Ÿ”ข ๐Ÿ‡
โ†ฉ๏ธ matchPosition
๐Ÿ‰
โ“๐Ÿ“ โžก๏ธ ๐Ÿฌ๐Ÿ”ข ๐Ÿ‡
โ†ฉ๏ธ matchLength
๐Ÿ‰
๐Ÿ‰
๐Ÿ“— A Regular Expression Engine using Emoji Syntax ๐Ÿ“—
๐Ÿ‡ ๐Ÿ”ญ ๐Ÿ‡
๐Ÿ–๏ธ๐Ÿ†•OPEN_SET๐Ÿ”ก โฌ…๏ธ ๐Ÿ”ค๐Ÿฟ๐Ÿ”ค
๐Ÿ–๏ธ๐Ÿ†•CLOSE_SET๐Ÿ”ก โฌ…๏ธ ๐Ÿ”ค๐Ÿ†๐Ÿ”ค
๐Ÿ–๏ธ๐Ÿ†•OPEN_GROUP๐Ÿ”ก โฌ…๏ธ ๐Ÿ”ค๐Ÿคœ๐Ÿ”ค
๐Ÿ–๏ธ๐Ÿ†•CLOSE_GROUP๐Ÿ”ก โฌ…๏ธ ๐Ÿ”ค๐Ÿค›๐Ÿ”ค
๐Ÿ–๏ธ๐Ÿ†•ALTERNATE๐Ÿ”ก โฌ…๏ธ ๐Ÿ”ค๐Ÿ‘๐Ÿ”ค
๐Ÿ–๏ธ๐Ÿ†•ZERO_TO_MANY๐Ÿ”ก โฌ…๏ธ ๐Ÿ”ค๐Ÿ”˜๐Ÿ”ค
๐Ÿ–๏ธ๐Ÿ†•ONE_TO_MANY๐Ÿ”ก โฌ…๏ธ ๐Ÿ”ค๐Ÿบ๐Ÿ”ค
๐Ÿ–๏ธ๐Ÿ†•ZERO_OR_ONE๐Ÿ”ก โฌ…๏ธ ๐Ÿ”ค๐Ÿฌ๐Ÿ”ค
๐Ÿ–๏ธ๐Ÿ†•ANY_CHARACTER๐Ÿ”ก โฌ…๏ธ ๐Ÿ”คโšช๐Ÿ”ค
๐Ÿ–๏ธ๐Ÿ†•INPUT_START๐Ÿ”ก โฌ…๏ธ ๐Ÿ”ค๐Ÿ‡๐Ÿ”ค
๐Ÿ–๏ธ๐Ÿ†•INPUT_END๐Ÿ”ก โฌ…๏ธ ๐Ÿ”ค๐Ÿ‰๐Ÿ”ค
๐Ÿ–๏ธ๐Ÿ†•ESCAPE๐Ÿ”ก โฌ…๏ธ ๐Ÿ”คโŒโŒ๐Ÿ”ค
๐Ÿ–๏ธ๐Ÿ†•CLASS_WORD_ID๐Ÿ”ก โฌ…๏ธ ๐Ÿ”ค๐Ÿ”ก๐Ÿ”ค
๐Ÿ–๏ธ๐Ÿ†•CLASS_WORD๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† โฌ…๏ธ ๐ŸŽถ๐Ÿ”คabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ๐Ÿ”คโ—
๐Ÿ–๏ธ๐Ÿ†•CLASS_DIGIT_ID๐Ÿ”ก โฌ…๏ธ ๐Ÿ”ค๐Ÿ”ข๐Ÿ”ค
๐Ÿ–๏ธ๐Ÿ†•CLASS_DIGIT๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† โฌ…๏ธ ๐ŸŽถ๐Ÿ”ค0123456789๐Ÿ”คโ—
๐Ÿ–๏ธ๐Ÿ†•CLASS_WHITESPACE_ID๐Ÿ”ก โฌ…๏ธ ๐Ÿ”คโšซ๐Ÿ”ค
๐Ÿ–๏ธ๐Ÿ†•CLASS_WHITESPACE๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† โฌ…๏ธ ๐ŸŽถ๐Ÿ”ค โŒrโŒnโŒt๐Ÿ”คโ—
๐Ÿ–๏ธ๐Ÿ†•SPECIAL_CHARS๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ†
๐Ÿ†• ๐Ÿ‡
๐Ÿฟ
OPEN_SET
CLOSE_SET
OPEN_GROUP
CLOSE_GROUP
ALTERNATE
ZERO_TO_MANY
ONE_TO_MANY
ZERO_OR_ONE
ANY_CHARACTER
INPUT_START
INPUT_END
ESCAPE
๐Ÿ† โžก๏ธ ๐Ÿ–๏ธSPECIAL_CHARS
๐Ÿ‰
๐Ÿ“— finds the first occurrence of the specified pattern in the specified string ๐Ÿ“—
โ—๐Ÿ‘€ pattern๐Ÿ”ก string๐Ÿ”ก โžก๏ธ ๐Ÿ–ผ๏ธ ๐Ÿ‡
๐ŸŽถpatternโ— โžก๏ธ ๐Ÿ–๏ธ๐Ÿ†•patternChars
๐ŸŽถstringโ— โžก๏ธ stringChars
๐Ÿ“stringCharsโ“ โžก๏ธ stringLength
0 โžก๏ธ ๐Ÿ–๏ธ๐Ÿ†•matchPosition
stringLength โž– 1 โžก๏ธ ๐Ÿ–๏ธ๐Ÿ†•maxMatchPosition
โ†ช๏ธ ๐ŸฝpatternChars 0โ— ๐Ÿ™Œ INPUT_START ๐Ÿ‡
0 โžก๏ธ ๐Ÿ–๏ธmaxMatchPosition
๐ŸจpatternChars 0โ—
๐Ÿ‰
๐Ÿ”
matchPosition โ—€๏ธ๐Ÿ™Œ maxMatchPosition ๐Ÿค
matchPosition โ—€๏ธ stringLength
๐Ÿ‡
๐Ÿ”ช๐Ÿ‘‡ stringChars matchPosition ๐Ÿคท โ— โžก๏ธ substringChars
๐Ÿ‘๏ธ๐Ÿ‘‡ patternChars substringChars 0 โ— โžก๏ธ result
โ†ช๏ธ ๐Ÿ‘Œresultโ“ ๐Ÿ‡
โ†ฉ๏ธ ๐Ÿ†•๐Ÿ–ผ๏ธ ๐Ÿ‘ matchPosition ๐Ÿบ๐Ÿ“resultโ“ โ—
๐Ÿ‰
matchPosition โฌ…๏ธโž• 1
๐Ÿ‰
โ†ฉ๏ธ ๐Ÿ†•๐Ÿ–ผ๏ธ ๐Ÿ‘Ž ๐Ÿคท ๐Ÿคท โ—
๐Ÿ‰
๐Ÿ“—
Matches the specified pattern at the start of the specified string
matchLength: the length of the match prior to this match
๐Ÿ“—
โ—๐Ÿ‘๏ธ pattern๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† string๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† matchLength๐Ÿ”ข โžก๏ธ ๐Ÿ–ผ๏ธ ๐Ÿ‡
โ†ช๏ธ ๐Ÿ“patternโ“ ๐Ÿ™Œ 0 ๐Ÿ‡
โ†ฉ๏ธ ๐Ÿ†•๐Ÿ–ผ๏ธ ๐Ÿ‘ 0 matchLength โ—
๐Ÿ‰ ๐Ÿ™…โ†ช๏ธ ๐Ÿฝpattern 0โ— ๐Ÿ™Œ INPUT_END ๐Ÿ‡
โ†ช๏ธ ๐Ÿ“stringโ“ ๐Ÿ™Œ 0 ๐Ÿ‡
โ†ฉ๏ธ ๐Ÿ†•๐Ÿ–ผ๏ธ ๐Ÿ‘ 0 matchLength โ—
๐Ÿ‰ ๐Ÿ™… ๐Ÿ‡
โ†ฉ๏ธ ๐Ÿ†•๐Ÿ–ผ๏ธ ๐Ÿ‘Ž ๐Ÿคท ๐Ÿคท โ—
๐Ÿ‰
๐Ÿ‰ ๐Ÿ™…โ†ช๏ธ ๐Ÿ“stringโ“ ๐Ÿ™Œ 0 ๐Ÿ‡
โ†ฉ๏ธ ๐Ÿ†•๐Ÿ–ผ๏ธ ๐Ÿ‘Ž ๐Ÿคท ๐Ÿคท โ—
๐Ÿ‰
๐Ÿบ๐Ÿ”ซ๐Ÿ‘‡ pattern โ— โžก๏ธ result
๐Ÿฝresult 0โ— โžก๏ธ head
๐Ÿฝresult 1โ— โžก๏ธ operatorArray
๐Ÿ”ค๐Ÿ”ค โžก๏ธ ๐Ÿ–๏ธ๐Ÿ†•operator
โ†ช๏ธ โŽ๐Ÿ“operatorArrayโ“ ๐Ÿ™Œ 0โ— ๐Ÿ‡
๐ŸฝoperatorArray 0โ— โžก๏ธ ๐Ÿ–๏ธoperator
๐Ÿ‰
๐Ÿฝresult 2โ— โžก๏ธ rest
โ†ช๏ธ operator ๐Ÿ™Œ ZERO_TO_MANY ๐Ÿ‡
โ†ฉ๏ธ ๐Ÿ‘“๐Ÿ‘‡ pattern string matchLength 0 ๐Ÿคทโ—
๐Ÿ‰ ๐Ÿ™…โ†ช๏ธ operator ๐Ÿ™Œ ONE_TO_MANY ๐Ÿ‡
โ†ฉ๏ธ ๐Ÿ‘“๐Ÿ‘‡ pattern string matchLength 1 ๐Ÿคทโ—
๐Ÿ‰ ๐Ÿ™…โ†ช๏ธ operator ๐Ÿ™Œ ZERO_OR_ONE ๐Ÿ‡
โ†ฉ๏ธ ๐Ÿ‘“๐Ÿ‘‡ pattern string matchLength 0 1โ—
๐Ÿ‰ ๐Ÿ™…โ†ช๏ธ ๐Ÿ†Ž๐Ÿ‘‡ headโ“ ๐Ÿ‡
โ†ฉ๏ธ ๐Ÿ†Ž๐Ÿ‘‡ pattern string matchLengthโ—
๐Ÿ‰ ๐Ÿ™…โ†ช๏ธ ๐Ÿ’ผ๐Ÿ‘‡ headโ“ ๐Ÿ‡
๐Ÿ’ผ๐Ÿ‘‡pattern stringโ— โžก๏ธ unitMatches
โ†ช๏ธ unitMatches ๐Ÿ‡
โ†ฉ๏ธ ๐Ÿ‘๏ธ๐Ÿ‘‡ rest ๐Ÿ”ช๐Ÿ‘‡ string 1 ๐Ÿคทโ— matchLength โž• 1โ—
๐Ÿ‰
๐Ÿ‰
โ†ฉ๏ธ ๐Ÿ†•๐Ÿ–ผ๏ธ ๐Ÿ‘Ž ๐Ÿคท ๐Ÿคทโ—
๐Ÿ‰
๐Ÿ“—
Matches the specified pattern multiple times at the start of the specified string
matchLength: the length of the match prior to this match
minMatches: the minimum number of matches to allow
maxMatches: the maximum number of matches to allow (inclusive)
๐Ÿ“—
โ—๐Ÿ‘“ pattern๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† string๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† matchLength๐Ÿ”ข minMatches๐Ÿ”ข maxMatches๐Ÿฌ๐Ÿ”ข โžก๏ธ ๐Ÿ–ผ๏ธ ๐Ÿ‡
๐Ÿบ๐Ÿ”ซ๐Ÿ‘‡ pattern โ— โžก๏ธ splitPattern
๐ŸฝsplitPattern 0โ— โžก๏ธ head
๐ŸฝsplitPattern 2โ— โžก๏ธ rest
0 โžก๏ธ ๐Ÿ–๏ธ๐Ÿ†•matchedTimes
๐Ÿ‘Ž โžก๏ธ ๐Ÿ–๏ธ๐Ÿ†•discoveryDone
๐Ÿ”
โŽdiscoveryDoneโ— ๐Ÿค
matchedTimes โ—€๏ธ ๐Ÿ“stringโ“ ๐Ÿค
๐Ÿคœ
maxMatches ๐Ÿ™Œ ๐Ÿคท ๐Ÿ‘
matchedTimes โ—€๏ธ ๐ŸบmaxMatches
๐Ÿค›
๐Ÿ‡
๐Ÿ“‹๐Ÿ‘‡head matchedTimesโž•1โ— โžก๏ธ patternRepeated
๐Ÿ‘๏ธ๐Ÿ‘‡ patternRepeated string matchLengthโ— โžก๏ธ result
โ†ช๏ธ ๐Ÿ‘Œresultโ“ ๐Ÿ‡
matchedTimes โฌ…๏ธโž• 1
๐Ÿ‰ ๐Ÿ™… ๐Ÿ‡
๐Ÿ‘ โžก๏ธ ๐Ÿ–๏ธdiscoveryDone
๐Ÿ‰
๐Ÿ‰
๐Ÿ” matchedTimes โ–ถ๏ธ๐Ÿ™Œ minMatches ๐Ÿ‡
๐Ÿ“‹๐Ÿ‘‡head matchedTimesโ— โžก๏ธ patternRepeated
๐Ÿ‘๏ธ๐Ÿ‘‡ ๐Ÿช๐Ÿ‘‡๐ŸฟpatternRepeated rest๐Ÿ†โ— string matchLengthโ— โžก๏ธ result
โ†ช๏ธ ๐Ÿ‘Œresultโ“ ๐Ÿ‡
โ†ฉ๏ธ ๐Ÿ†•๐Ÿ–ผ๏ธ ๐Ÿ‘ 0 matchLengthโ—
๐Ÿ‰
matchedTimes โฌ…๏ธโž– 1
๐Ÿ‰
โ†ฉ๏ธ ๐Ÿ†•๐Ÿ–ผ๏ธ ๐Ÿ‘Ž ๐Ÿคท ๐Ÿคท โ—
๐Ÿ‰
๐Ÿ“— Joins multiple character arrays into a single character array ๐Ÿ“—
โ—๐Ÿช strings๐Ÿจ๐Ÿš๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ†๐Ÿ† โžก๏ธ ๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† ๐Ÿ‡
๐Ÿ†•๐Ÿ” โ— โžก๏ธ builder
๐Ÿ”‚string strings๐Ÿ‡
๐Ÿ”‚char string๐Ÿ‡
๐Ÿปbuilder charโ—
๐Ÿ‰
๐Ÿ‰
๐Ÿ”กbuilderโ— โžก๏ธ fullString
โ†ฉ๏ธ ๐ŸŽถfullStringโ—
๐Ÿ‰
๐Ÿ“— Splits a pattern into a head, operator, and the remainder ๐Ÿ“—
โ—๐Ÿ”ซ pattern๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† โžก๏ธ ๐Ÿจ๐Ÿš๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ†๐Ÿ† ๐Ÿšง๐Ÿšง ๐Ÿ‡
๐Ÿ†•๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ†โ— โžก๏ธ ๐Ÿ–๏ธ๐Ÿ†•head
๐Ÿ†•๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ†โ— โžก๏ธ ๐Ÿ–๏ธ๐Ÿ†•operator
๐Ÿ†•๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ†โ— โžก๏ธ ๐Ÿ–๏ธ๐Ÿ†•rest
-1 โžก๏ธ ๐Ÿ–๏ธ๐Ÿ†•restStartPosition
๐Ÿฝpattern 0โ— โžก๏ธ firstChar
โ†ช๏ธ firstChar ๐Ÿ™Œ OPEN_SET ๐Ÿ‡
๐Ÿบ๐Ÿ”๐Ÿ‘‡ pattern CLOSE_SETโ“ โž• 1 โžก๏ธ ๐Ÿ–๏ธrestStartPosition
๐Ÿ”ช๐Ÿ‘‡pattern 0 restStartPositionโ— โžก๏ธ ๐Ÿ–๏ธhead
๐Ÿ‰ ๐Ÿ™…โ†ช๏ธ firstChar ๐Ÿ™Œ OPEN_GROUP ๐Ÿ‡
๐Ÿบ๐Ÿ”๐Ÿ‘‡ pattern CLOSE_GROUPโ“ โž• 1 โžก๏ธ ๐Ÿ–๏ธrestStartPosition
๐Ÿ”ช๐Ÿ‘‡pattern 0 restStartPositionโ— โžก๏ธ ๐Ÿ–๏ธhead
๐Ÿ‰ ๐Ÿ™…โ†ช๏ธ ๐Ÿ”ฝ๐Ÿ‘‡ firstCharโ“ ๐Ÿ‘ firstChar ๐Ÿ™Œ ANY_CHARACTER ๐Ÿ‡
1 โžก๏ธ ๐Ÿ–๏ธrestStartPosition
๐ŸฟfirstChar๐Ÿ† โžก๏ธ ๐Ÿ–๏ธhead
๐Ÿ‰ ๐Ÿ™…โ†ช๏ธ firstChar ๐Ÿ™Œ ESCAPE ๐Ÿ‡
2 โžก๏ธ ๐Ÿ–๏ธrestStartPosition
๐Ÿ”ช๐Ÿ‘‡pattern 0 2โ— โžก๏ธ ๐Ÿ–๏ธhead
๐Ÿ‰ ๐Ÿ™… ๐Ÿ‡
๐Ÿšจ๐Ÿ†•๐Ÿšง๐Ÿ”คUnrecognized start of expression: ๐ŸงฒfirstChar๐Ÿงฒ๐Ÿ”คโ—
๐Ÿ‰
โ†ช๏ธ restStartPosition โ—€๏ธ ๐Ÿ“patternโ“ ๐Ÿค ๐Ÿ‘ท๐Ÿ‘‡ ๐Ÿฝpattern restStartPositionโ— โ“ ๐Ÿ‡
๐Ÿปoperator ๐Ÿฝpattern restStartPositionโ—โ—
restStartPosition โฌ…๏ธโž• 1
๐Ÿ‰
๐Ÿ”ช๐Ÿ‘‡ pattern restStartPosition ๐Ÿคทโ— โžก๏ธ ๐Ÿ–๏ธrest
โ†ฉ๏ธ ๐Ÿฟ head operator rest ๐Ÿ†
๐Ÿ‰
๐Ÿ“— returns whether the character is an operator ๐Ÿ“—
โ“๐Ÿ‘ท char๐Ÿ”ก โžก๏ธ ๐Ÿ‘Œ ๐Ÿ‡
โ†ฉ๏ธ โŽchar ๐Ÿ™Œ ๐Ÿ”ค๐Ÿ”คโ— ๐Ÿค ๐Ÿฆ๐Ÿฟ ZERO_OR_ONE ONE_TO_MANY ZERO_TO_MANY ๐Ÿ† charโ“
๐Ÿ‰
๐Ÿ“— Returns whether the pattern is a single "unit" ๐Ÿ“—
โ“๐Ÿ’ผ pattern๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† โžก๏ธ ๐Ÿ‘Œ ๐Ÿ‡
โ†ช๏ธ ๐Ÿ“patternโ“ ๐Ÿ™Œ 0 ๐Ÿ‡
โ†ฉ๏ธ ๐Ÿ‘Ž
๐Ÿ‰
๐Ÿฝpattern 0โ— โžก๏ธ firstChar
โ†ฉ๏ธ ๐Ÿ”ฝ๐Ÿ‘‡firstCharโ“ ๐Ÿ‘
๐Ÿฆ๐Ÿ‘‡patternโ“ ๐Ÿ‘
firstChar ๐Ÿ™Œ ANY_CHARACTER ๐Ÿ‘
๐Ÿงฏ๐Ÿ‘‡patternโ“
๐Ÿ‰
๐Ÿ“— Matches the "unit" at the start of the string ๐Ÿ“—
โ—๐Ÿ’ผ pattern๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† string๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† โžก๏ธ ๐Ÿ‘Œ ๐Ÿ‡
๐Ÿบ๐Ÿ”ซ๐Ÿ‘‡ patternโ— โžก๏ธ parts
๐Ÿฝparts 0โ— โžก๏ธ head
๐Ÿฝhead 0โ— โžก๏ธ firstChar
โ†ช๏ธ firstChar ๐Ÿ™Œ ANY_CHARACTER ๐Ÿ‡
โ†ฉ๏ธ ๐Ÿ“stringโ“ โ–ถ๏ธ 0
๐Ÿ‰ ๐Ÿ™…โ†ช๏ธ ๐Ÿ”ฝ๐Ÿ‘‡firstCharโ“ ๐Ÿ‡
โ†ฉ๏ธ firstChar ๐Ÿ™Œ ๐Ÿฝstring 0โ—
๐Ÿ‰ ๐Ÿ™…โ†ช๏ธ ๐Ÿงฏ๐Ÿ‘‡headโ“ ๐Ÿ‡
โ†ฉ๏ธ ๐Ÿบ๐Ÿงฏ๐Ÿ‘‡head stringโ—
๐Ÿ‰ ๐Ÿ™…โ†ช๏ธ ๐Ÿฆ๐Ÿ‘‡headโ“ ๐Ÿ‡
โ†ฉ๏ธ ๐Ÿฆ๐Ÿ‘‡head stringโ—
๐Ÿ‰
โ†ฉ๏ธ ๐Ÿ‘Ž
๐Ÿ‰
๐Ÿ“— returns whether the pattern is a set ๐Ÿ“—
โ“๐Ÿฆ pattern๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† โžก๏ธ ๐Ÿ‘Œ ๐Ÿ‡
โ†ฉ๏ธ ๐Ÿ“patternโ“ โ–ถ๏ธ 0 ๐Ÿค
๐Ÿฝpattern 0โ— ๐Ÿ™Œ OPEN_SET ๐Ÿค
๐Ÿฝpattern ๐Ÿ“patternโ“โž–1โ— ๐Ÿ™Œ CLOSE_SET
๐Ÿ‰
๐Ÿ“— returns whether the given set pattern matches at the start of the string ๐Ÿ“—
โ—๐Ÿฆ pattern๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† string๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† โžก๏ธ ๐Ÿ‘Œ ๐Ÿ‡
pattern โžก๏ธ ๐Ÿ–๏ธ๐Ÿ†•patternCopy
๐Ÿ’ญ remove first and last character in pattern (start and end set chars)
๐ŸจpatternCopy 0โ—
๐ŸจpatternCopy ๐Ÿ“patternCopyโ“ โž– 1โ—
โ†ฉ๏ธ ๐ŸฆpatternCopy ๐Ÿฝstring 0โ—โ“
๐Ÿ‰
๐Ÿ“— returns whether the character is a 'literal' (non-special) character ๐Ÿ“—
โ“๐Ÿ”ฝ char๐Ÿ”ก โžก๏ธ ๐Ÿ‘Œ ๐Ÿ‡
โ†ฉ๏ธ โŽchar ๐Ÿ™Œ ๐Ÿ”ค๐Ÿ”คโ— ๐Ÿค โŽ๐ŸฆSPECIAL_CHARS charโ“โ—
๐Ÿ‰
๐Ÿ“— returns whether the pattern is an escape sequence ๐Ÿ“—
โ“๐Ÿงฏ pattern๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† โžก๏ธ ๐Ÿ‘Œ ๐Ÿ‡
โ†ฉ๏ธ ๐Ÿ“patternโ“ โ–ถ๏ธ 0 ๐Ÿค ๐Ÿฝpattern 0โ— ๐Ÿ™Œ ESCAPE
๐Ÿ‰
๐Ÿ“—
matches the specified escape sequence at the start of the string
throws an error if unrecognized escape sequence detected
๐Ÿ“—
โ—๐Ÿงฏ pattern๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† string๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† โžก๏ธ ๐Ÿ‘Œ ๐Ÿšง๐Ÿšง ๐Ÿ‡
๐Ÿฝpattern 1โ— โžก๏ธ escapeId
๐Ÿฝstring 0โ— โžก๏ธ char
โ†ช๏ธ escapeId ๐Ÿ™Œ CLASS_WORD_ID ๐Ÿ‡
โ†ฉ๏ธ ๐ŸฆCLASS_WORD charโ“
๐Ÿ‰ ๐Ÿ™…โ†ช๏ธ escapeId ๐Ÿ™Œ CLASS_DIGIT_ID ๐Ÿ‡
โ†ฉ๏ธ ๐ŸฆCLASS_DIGIT charโ“
๐Ÿ‰ ๐Ÿ™…โ†ช๏ธ escapeId ๐Ÿ™Œ CLASS_WHITESPACE_ID ๐Ÿ‡
โ†ฉ๏ธ ๐ŸฆCLASS_WHITESPACE charโ“
๐Ÿ‰ ๐Ÿ™…โ†ช๏ธ ๐ŸฆSPECIAL_CHARS escapeIdโ“ ๐Ÿ‡
โ†ฉ๏ธ escapeId ๐Ÿ™Œ char
๐Ÿ‰
๐Ÿ”ก๐Ÿ‘‡ patternโ— โžก๏ธ patternString
๐Ÿšจ๐Ÿ†•๐Ÿšง๐Ÿ”คUnrecognized escape sequence: ๐ŸงฒpatternString๐Ÿงฒ๐Ÿ”คโ—
๐Ÿ‰
๐Ÿ“— returns whether the pattern is an alternate expression ๐Ÿ“—
โ“๐Ÿ†Ž pattern๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† โžก๏ธ ๐Ÿ‘Œ ๐Ÿ‡
โ†ฉ๏ธ ๐Ÿ“patternโ“ โ–ถ๏ธ 0 ๐Ÿค
๐Ÿฝpattern 0โ— ๐Ÿ™Œ OPEN_GROUP ๐Ÿค
๐Ÿฝpattern ๐Ÿ“patternโ“โž–1โ— ๐Ÿ™Œ CLOSE_GROUP ๐Ÿค
๐Ÿฆpattern ALTERNATEโ“
๐Ÿ‰
๐Ÿ“— matches the alternate expression at the start of the string ๐Ÿ“—
โ—๐Ÿ†Ž pattern๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† string๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† matchLength๐Ÿ”ข โžก๏ธ ๐Ÿ–ผ๏ธ ๐Ÿ‡
๐Ÿบ๐Ÿ”ซ๐Ÿ‘‡patternโ— โžก๏ธ split
๐Ÿฝsplit 0โ— โžก๏ธ head
๐Ÿฝsplit 2โ— โžก๏ธ rest
โš”๏ธ๐Ÿ‘‡headโ— โžก๏ธ options
๐Ÿ”‚ option options ๐Ÿ‡
๐Ÿ‘๏ธ๐Ÿ‘‡ ๐Ÿช๐Ÿ‘‡๐Ÿฟoption rest๐Ÿ†โ— string matchLength โ— โžก๏ธ result
โ†ช๏ธ ๐Ÿ‘Œresultโ“ ๐Ÿ‡
โ†ฉ๏ธ ๐Ÿ†•๐Ÿ–ผ๏ธ ๐Ÿ‘ 0 ๐Ÿ“resultโ“ โ—
๐Ÿ‰
๐Ÿ‰
โ†ฉ๏ธ ๐Ÿ†•๐Ÿ–ผ๏ธ ๐Ÿ‘Ž ๐Ÿคท ๐Ÿคทโ—
๐Ÿ‰
๐Ÿ“— splits all alternates in the expression into their own character array ๐Ÿ“—
โ—โš”๏ธ pattern๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† โžก๏ธ ๐Ÿจ๐Ÿš๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ†๐Ÿ† ๐Ÿ‡
๐Ÿ”ช๐Ÿ‘‡ pattern 1 ๐Ÿ“patternโ“โž–2 โ— โžก๏ธ slice
๐Ÿ”ก๐Ÿ‘‡ sliceโ— โžก๏ธ substring
๐Ÿ”ซsubstring ALTERNATEโ— โžก๏ธ alternateStrings
โ†ฉ๏ธ ๐ŸฐalternateStrings ๐Ÿ‡ alternateString๐Ÿ”ก โžก๏ธ ๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ†
โ†ฉ๏ธ ๐ŸŽถalternateStringโ—
๐Ÿ‰โ—
๐Ÿ‰
๐Ÿ“— converts a char array into a string ๐Ÿ“—
โ—๐Ÿ”ก charArray๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† โžก๏ธ ๐Ÿ”ก ๐Ÿ‡
๐Ÿ†•๐Ÿ” โ— โžก๏ธ builder
๐Ÿ”‚ char charArray ๐Ÿ‡
๐Ÿปbuilder charโ—
๐Ÿ‰
โ†ฉ๏ธ ๐Ÿ”กbuilderโ—
๐Ÿ‰
๐Ÿ“— Duplicates the char array multiple times into a single array ๐Ÿ“—
โ—๐Ÿ“‹ string๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† times๐Ÿ”ข โžก๏ธ ๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† ๐Ÿ‡
๐Ÿ†•๐Ÿจ๐Ÿš๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ†๐Ÿ†โ— โžก๏ธ ๐Ÿ–๏ธ๐Ÿ†•strings
๐Ÿ”‚ i ๐Ÿ†•โฉ 0 times 1โ— ๐Ÿ‡
๐Ÿปstrings stringโ—
๐Ÿ‰
โ†ฉ๏ธ ๐Ÿช๐Ÿ‘‡stringsโ—
๐Ÿ‰
๐Ÿ’ญ TODO: contribute this back to Emojicode repository (array slice)
๐Ÿ“— Returns a new list consisting of length elements beginning from the element at index from in this list. Complexity: O(n). ๐Ÿ“—
โ—๐Ÿ”ช list๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† from๐Ÿ”ข length๐Ÿฌ๐Ÿ”ข โžก๏ธ ๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† ๐Ÿ‡
๐Ÿ“listโ“ โžก๏ธ ๐Ÿ–๏ธ๐Ÿ†•end
โ†ช๏ธ โŽ length ๐Ÿ™Œ ๐Ÿคท โ— ๐Ÿค from โž• ๐Ÿบlength โ—€๏ธ ๐Ÿ“listโ“ ๐Ÿ‡
from โž• ๐Ÿบlength โžก๏ธ ๐Ÿ–๏ธend
๐Ÿ‰
๐Ÿ†•๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ†โ–ถ๏ธ๐Ÿด end โž– from โ— โžก๏ธ ๐Ÿ–๏ธ๐Ÿ†•output
๐Ÿ”‚ i ๐Ÿ†•โฉ from end 1 โ— ๐Ÿ‡
๐Ÿปoutput ๐Ÿฝlist iโ—โ—
๐Ÿ‰
โ†ฉ๏ธ output
๐Ÿ‰
๐Ÿ’ญ TODO: contribute this back to Emojicode repository (array indexOf)
๐Ÿ“—
Finds the first occurrences of element in this list. Search is performed in list order.
Returns the index of the first occurrence or no value if search does not occur.
๐Ÿ“—
โ“๐Ÿ” list๐Ÿจ๐Ÿš๐Ÿ”ก๐Ÿ† search๐Ÿ”ก โžก๏ธ ๐Ÿฌ๐Ÿ”ข ๐Ÿ‡
0 โžก๏ธ ๐Ÿ–๏ธ๐Ÿ†• index
๐Ÿ”‚ element list ๐Ÿ‡
โ†ช๏ธ element ๐Ÿ™Œ search ๐Ÿ‡
โ†ฉ๏ธ index
๐Ÿ‰
index โฌ…๏ธโž• 1
๐Ÿ‰
โ†ฉ๏ธ ๐Ÿคท
๐Ÿ‰
๐Ÿ‰
๐Ÿ“ฆ testtube ๐Ÿ 
๐Ÿ“œ ๐Ÿ”คregex.๐Ÿ‡๐Ÿ”ค
๐Ÿ โžก๏ธ ๐Ÿ”ข ๐Ÿ‡
โ†ฉ๏ธ ๐Ÿ‘”๐Ÿ†•๐Ÿง‘โ€๐Ÿ”ฌโ—๏ธโ—๏ธ
๐Ÿ‰
๐Ÿ‡ ๐Ÿง‘โ€๐Ÿ”ฌ ๐Ÿงช ๐Ÿ‡
โœ’๏ธ โ—๏ธ ๐Ÿ ๐Ÿ‡
๐Ÿ†•๐Ÿ”ญโ— โžก๏ธ regex
๐Ÿ’ญ NO MATCH
โŽ๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คabc๐Ÿ”ค ๐Ÿ”คcba๐Ÿ”คโ—โ“
๐Ÿ”คliteral pattern should not match the reversed string๐Ÿ”ค
โ—
โ›”๐Ÿ‘‡
๐Ÿฝ๐Ÿ‘€regex ๐Ÿ”คabc๐Ÿ”ค ๐Ÿ”คcba๐Ÿ”คโ—โ“ ๐Ÿ™Œ ๐Ÿคท
๐Ÿ”คmatch failure should have no value for match index๐Ÿ”ค
โ—
โ›”๐Ÿ‘‡
๐Ÿ“๐Ÿ‘€regex ๐Ÿ”คabc๐Ÿ”ค ๐Ÿ”คcba๐Ÿ”คโ—โ“ ๐Ÿ™Œ ๐Ÿคท
๐Ÿ”คmatch failure should have no value for match length๐Ÿ”ค
โ—
๐Ÿ’ญ LITERAL PATTERN - FULL STRING MATCH
โ›”๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คabc๐Ÿ”ค ๐Ÿ”คabc๐Ÿ”คโ—โ“
๐Ÿ”คliteral pattern should match the exact string๐Ÿ”ค
โ—
๐Ÿ”ข๐Ÿ‘‡
๐Ÿบ๐Ÿฝ๐Ÿ‘€regex ๐Ÿ”คabc๐Ÿ”ค ๐Ÿ”คabc๐Ÿ”คโ—โ“
0
๐Ÿ”คliteral pattern should be found at the correct index๐Ÿ”ค
โ—
๐Ÿ”ข๐Ÿ‘‡
๐Ÿบ๐Ÿ“๐Ÿ‘€regex ๐Ÿ”คabc๐Ÿ”ค ๐Ÿ”คabc๐Ÿ”คโ—โ“
3
๐Ÿ”คliteral pattern should be have correct match length๐Ÿ”ค
โ—
๐Ÿ’ญ LITERAL PATTERN - SUBSTRING MATCH
โ›”๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คabc๐Ÿ”ค ๐Ÿ”ค abc ๐Ÿ”คโ—โ“
๐Ÿ”คliteral substring pattern should match the exact string at any position๐Ÿ”ค
โ—
๐Ÿ”ข๐Ÿ‘‡
๐Ÿบ๐Ÿฝ๐Ÿ‘€regex ๐Ÿ”คabc๐Ÿ”ค ๐Ÿ”ค abc ๐Ÿ”คโ—โ“
5
๐Ÿ”คliteral substring pattern should be found at the correct index๐Ÿ”ค
โ—
๐Ÿ”ข๐Ÿ‘‡
๐Ÿบ๐Ÿ“๐Ÿ‘€regex ๐Ÿ”คabc๐Ÿ”ค ๐Ÿ”ค abc ๐Ÿ”คโ—โ“
3
๐Ÿ”คliteral substring pattern should be have correct match length๐Ÿ”ค
โ—
๐Ÿ’ญ PREFIX MATCH (๐Ÿ‡)
โ›”๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”ค๐Ÿ‡abc๐Ÿ”ค ๐Ÿ”คabc ๐Ÿ”คโ—โ“
๐Ÿ”คprefix pattern should match the string starting with that pattern๐Ÿ”ค
โ—
โŽ๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”ค๐Ÿ‡abc๐Ÿ”ค ๐Ÿ”ค abc ๐Ÿ”คโ—โ“
๐Ÿ”คprefix pattern should not match if string does not start with that pattern๐Ÿ”ค
โ—
๐Ÿ”ข๐Ÿ‘‡
๐Ÿบ๐Ÿฝ๐Ÿ‘€regex ๐Ÿ”ค๐Ÿ‡abc๐Ÿ”ค ๐Ÿ”คabc ๐Ÿ”คโ—โ“
0
๐Ÿ”คprefix pattern should be found at the correct index๐Ÿ”ค
โ—
๐Ÿ”ข๐Ÿ‘‡
๐Ÿบ๐Ÿ“๐Ÿ‘€regex ๐Ÿ”ค๐Ÿ‡abc๐Ÿ”ค ๐Ÿ”คabc ๐Ÿ”คโ—โ“
3
๐Ÿ”คprefix pattern should be have correct match length๐Ÿ”ค
โ—
๐Ÿ’ญ SUFFIX MATCH (๐Ÿ‰)
โ›”๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คabc๐Ÿ‰๐Ÿ”ค ๐Ÿ”ค abc๐Ÿ”คโ—โ“
๐Ÿ”คsuffix pattern should match the string ending with that pattern๐Ÿ”ค
โ—
โŽ๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คabc๐Ÿ‰๐Ÿ”ค ๐Ÿ”ค abc ๐Ÿ”คโ—โ“
๐Ÿ”คsuffix pattern should not match if string does not end with that pattern๐Ÿ”ค
โ—
๐Ÿ”ข๐Ÿ‘‡
๐Ÿบ๐Ÿฝ๐Ÿ‘€regex ๐Ÿ”คabc๐Ÿ‰๐Ÿ”ค ๐Ÿ”ค abc๐Ÿ”คโ—โ“
5
๐Ÿ”คsuffix pattern should be found at the correct index๐Ÿ”ค
โ—
๐Ÿ”ข๐Ÿ‘‡
๐Ÿบ๐Ÿ“๐Ÿ‘€regex ๐Ÿ”คabc๐Ÿ‰๐Ÿ”ค ๐Ÿ”ค abc๐Ÿ”คโ—โ“
3
๐Ÿ”คsuffix pattern should be have correct match length๐Ÿ”ค
โ—
๐Ÿ’ญ ZERO OR ONE / OPTIONAL (๐Ÿฌ)
โ›”๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คab๐Ÿฌc๐Ÿ”ค ๐Ÿ”คabc๐Ÿ”คโ—โ“
๐Ÿ”คoptional pattern should match the string with that pattern๐Ÿ”ค
โ—
โ›”๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คab๐Ÿฌc๐Ÿ”ค ๐Ÿ”คac๐Ÿ”คโ—โ“
๐Ÿ”คoptional pattern should match the string without that pattern๐Ÿ”ค
โ—
โŽ๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คab๐Ÿฌc๐Ÿ”ค ๐Ÿ”คabbc๐Ÿ”คโ—โ“
๐Ÿ”คoptional pattern should not match if string has too many of the optional๐Ÿ”ค
โ—
๐Ÿ’ญ ZERO OR MORE (๐Ÿ”˜)
โ›”๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คab๐Ÿ”˜c๐Ÿ”ค ๐Ÿ”คabc๐Ÿ”คโ—โ“
๐Ÿ”คzero or more pattern should match the string with that pattern๐Ÿ”ค
โ—
โ›”๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คab๐Ÿ”˜c๐Ÿ”ค ๐Ÿ”คac๐Ÿ”คโ—โ“
๐Ÿ”คzero or more pattern should match the string without that pattern๐Ÿ”ค
โ—
โ›”๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คab๐Ÿ”˜c๐Ÿ”ค ๐Ÿ”คabbbbbbbbbbbbbbbbbbbbbc๐Ÿ”คโ—โ“
๐Ÿ”คzero or more pattern should match if string has multiple of the optional๐Ÿ”ค
โ—
๐Ÿ’ญ ONE OR MORE (๐Ÿบ)
โ›”๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คab๐Ÿบc๐Ÿ”ค ๐Ÿ”คabc๐Ÿ”คโ—โ“
๐Ÿ”คone or more pattern should match the string with that pattern๐Ÿ”ค
โ—
โŽ๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คab๐Ÿบc๐Ÿ”ค ๐Ÿ”คac๐Ÿ”คโ—โ“
๐Ÿ”คone or more pattern should not match the string without that pattern๐Ÿ”ค
โ—
โ›”๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คab๐Ÿบc๐Ÿ”ค ๐Ÿ”คabbbbbbbbbbbbbbbbbbbbbc๐Ÿ”คโ—โ“
๐Ÿ”คone or more pattern should match if string has multiple of the optional๐Ÿ”ค
โ—
๐Ÿ’ญ SETS (๐ŸฟABC๐Ÿ†)
โ›”๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คa๐ŸฟABC๐Ÿ†c๐Ÿ”ค ๐Ÿ”คaAc๐Ÿ”คโ—โ“
๐Ÿ”คset pattern should match the string with any unit in the set๐Ÿ”ค
โ—
โ›”๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คa๐ŸฟABC๐Ÿ†c๐Ÿ”ค ๐Ÿ”คaBc๐Ÿ”คโ—โ“
๐Ÿ”คset pattern should match the string with any unit in the set๐Ÿ”ค
โ—
โ›”๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คa๐ŸฟABC๐Ÿ†c๐Ÿ”ค ๐Ÿ”คaCc๐Ÿ”คโ—โ“
๐Ÿ”คset pattern should match the string with any unit in the set๐Ÿ”ค
โ—
โŽ๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คa๐ŸฟABC๐Ÿ†c๐Ÿ”ค ๐Ÿ”คac๐Ÿ”คโ—โ“
๐Ÿ”คset pattern should not match the string without a unit from the set๐Ÿ”ค
โ—
โŽ๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คa๐ŸฟABC๐Ÿ†c๐Ÿ”ค ๐Ÿ”คaDc๐Ÿ”คโ—โ“
๐Ÿ”คset pattern should not match the string with a unit not in the set๐Ÿ”ค
โ—
โŽ๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คa๐ŸฟABC๐Ÿ†c๐Ÿ”ค ๐Ÿ”คaAAAAAAAAAAAc๐Ÿ”คโ—โ“
๐Ÿ”คset pattern should not match if string has multiple of the set unit๐Ÿ”ค
โ—
โŽ๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คa๐ŸฟABC๐Ÿ†c๐Ÿ”ค ๐Ÿ”คaABCc๐Ÿ”คโ—โ“
๐Ÿ”คset pattern should not match if string has multiple of the set unit๐Ÿ”ค
โ—
๐Ÿ’ญ ALTERNATES (๐ŸคœAB๐Ÿ‘C๐Ÿค›)
โ›”๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คa๐ŸคœAB๐Ÿ‘C๐Ÿค›c๐Ÿ”ค ๐Ÿ”คaABc๐Ÿ”คโ—โ“
๐Ÿ”คalternate pattern should match the string with any pattern in the alternate list๐Ÿ”ค
โ—
โ›”๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คa๐ŸคœAB๐Ÿ‘C๐Ÿค›c๐Ÿ”ค ๐Ÿ”คaCc๐Ÿ”คโ—โ“
๐Ÿ”คalternate pattern should match the string with any pattern in the alternate list๐Ÿ”ค
โ—
โŽ๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คa๐ŸคœAB๐Ÿ‘C๐Ÿค›c๐Ÿ”ค ๐Ÿ”คac๐Ÿ”คโ—โ“
๐Ÿ”คalternate pattern should not match the string without a pattern from the alternate list๐Ÿ”ค
โ—
โŽ๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คa๐ŸคœAB๐Ÿ‘C๐Ÿค›c๐Ÿ”ค ๐Ÿ”คaAc๐Ÿ”คโ—โ“
๐Ÿ”คalternate pattern should not match the string with a pattern not in the alternate list๐Ÿ”ค
โ—
โŽ๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คa๐ŸคœAB๐Ÿ‘C๐Ÿค›c๐Ÿ”ค ๐Ÿ”คaCCCCCCCCCCc๐Ÿ”คโ—โ“
๐Ÿ”คalternate pattern should not match if string has multiple of the alternate list๐Ÿ”ค
โ—
โŽ๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คa๐ŸคœAB๐Ÿ‘C๐Ÿค›c๐Ÿ”ค ๐Ÿ”คaABCc๐Ÿ”คโ—โ“
๐Ÿ”คalternate pattern should not match if string has multiple of the alternate list๐Ÿ”ค
โ—
๐Ÿ’ญ ANY CHARACTER (โšช)
๐Ÿ”‚ char ๐ŸŽถ
๐Ÿ”คb ๐Ÿ‘ช0๐Ÿ‘~๐Ÿ”ค
โ— ๐Ÿ‡
โ›”๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คaโšชc๐Ÿ”ค ๐Ÿ”คa๐Ÿงฒchar๐Ÿงฒc๐Ÿ”คโ—โ“
๐Ÿ”คany character token should match any character (๐Ÿงฒchar๐Ÿงฒ)๐Ÿ”ค
โ—
๐Ÿ‰
โŽ๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คaโšชc๐Ÿ”ค ๐Ÿ”คac๐Ÿ”คโ—โ“
๐Ÿ”คany character token should not match no character๐Ÿ”ค
โ—
๐Ÿ’ญ ESCAPE (โŒ)
๐Ÿ”‚ char ๐ŸŽถ
๐Ÿ”ค๐Ÿฟ๐Ÿ†๐Ÿคœ๐Ÿค›๐Ÿ‘๐Ÿ”˜๐Ÿบ๐Ÿฌโšช๐Ÿ‡๐Ÿ‰โŒโŒ๐Ÿ”ค
โ— ๐Ÿ‡
โ›”๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คaโŒโŒ๐Ÿงฒchar๐Ÿงฒc๐Ÿ”ค ๐Ÿ”คa๐Ÿงฒchar๐Ÿงฒc๐Ÿ”คโ—โ“
๐Ÿ”คa pattern escaping a special character should match that literal character (๐Ÿงฒchar๐Ÿงฒ)๐Ÿ”ค
โ—
๐Ÿ‰
๐Ÿ’ญ๐Ÿ”œ
๐Ÿ’ญ ๐Ÿ’ญ TODO: There isn't a way to test this since I declared it not-error-prone. When I refactor, I will need to make sure this test case works as expected.
๐Ÿ’ญ ๐Ÿ‡ โžก๏ธ โšช ๐Ÿšง๐Ÿšง
๐Ÿ’ญ โ†ฉ๏ธ ๐Ÿ‘€regex ๐Ÿ”คaโŒโŒ c๐Ÿ”ค ๐Ÿ”คa c๐Ÿ”คโ—
๐Ÿ’ญ ๐Ÿ‰ โžก๏ธ invalidCall
๐Ÿ’ญ ๐Ÿ†— โ‰๏ธinvalidCallโ— ๐Ÿ‡
๐Ÿ’ญ ๐Ÿ™๐Ÿ‘‡ ๐Ÿ”คproviding an invalid escape sequence should throw an error๐Ÿ”ค โ—
๐Ÿ’ญ ๐Ÿ‰ ๐Ÿ™… error ๐Ÿ‡
๐Ÿ’ญ โœ…๐Ÿ‘‡ ๐Ÿ”คproviding an invalid escape sequence should throw an error๐Ÿ”ค โ—
๐Ÿ’ญ ๐Ÿ‰
๐Ÿ”š๐Ÿ’ญ
๐Ÿ’ญ WORD CHARACTER CLASS (โŒ๐Ÿ”ก)
๐Ÿ”‚ char ๐ŸŽถ
๐Ÿ”คabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ๐Ÿ”ค
โ— ๐Ÿ‡
โ›”๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คaโŒโŒ๐Ÿ”กc๐Ÿ”ค ๐Ÿ”คa๐Ÿงฒchar๐Ÿงฒc๐Ÿ”คโ—โ“
๐Ÿ”คa pattern including a word character escape sequence should allow any word character (๐Ÿงฒchar๐Ÿงฒ)๐Ÿ”ค
โ—
๐Ÿ‰
๐Ÿ”‚ char ๐ŸŽถ
๐Ÿ”ค0123456789 โŒtโŒrโŒn~๐Ÿ‘๐Ÿ‘ช,.-๐Ÿ”ค
โ— ๐Ÿ‡
โŽ๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คaโŒโŒ๐Ÿ”กc๐Ÿ”ค ๐Ÿ”คa๐Ÿงฒchar๐Ÿงฒc๐Ÿ”คโ—โ“
๐Ÿ”คa pattern including a word character escape sequence should not allow a character not included in the class (๐Ÿงฒchar๐Ÿงฒ)๐Ÿ”ค
โ—
๐Ÿ‰
๐Ÿ’ญ DIGIT CHARACTER CLASS (โŒ๐Ÿ”ข)
๐Ÿ”‚ char ๐ŸŽถ
๐Ÿ”ค0123456789๐Ÿ”ค
โ— ๐Ÿ‡
โ›”๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คaโŒโŒ๐Ÿ”ขc๐Ÿ”ค ๐Ÿ”คa๐Ÿงฒchar๐Ÿงฒc๐Ÿ”คโ—โ“
๐Ÿ”คa pattern including a digit character escape sequence should allow any digit character (๐Ÿงฒchar๐Ÿงฒ)๐Ÿ”ค
โ—
๐Ÿ‰
๐Ÿ”‚ char ๐ŸŽถ
๐Ÿ”คabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ โŒtโŒrโŒn~๐Ÿ‘๐Ÿ‘ช,.-๐Ÿ”ค
โ— ๐Ÿ‡
โŽ๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คaโŒโŒ๐Ÿ”ขc๐Ÿ”ค ๐Ÿ”คa๐Ÿงฒchar๐Ÿงฒc๐Ÿ”คโ—โ“
๐Ÿ”คa pattern including a digit character escape sequence should not allow a character not included in the class (๐Ÿงฒchar๐Ÿงฒ)๐Ÿ”ค
โ—
๐Ÿ‰
๐Ÿ’ญ WHITESPACE CHARACTER CLASS (โŒโšซ)
๐Ÿ”‚ char ๐ŸŽถ
๐Ÿ”ค โŒrโŒnโŒt๐Ÿ”ค
โ— ๐Ÿ‡
โ›”๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คaโŒโŒโšซc๐Ÿ”ค ๐Ÿ”คa๐Ÿงฒchar๐Ÿงฒc๐Ÿ”คโ—โ“
๐Ÿ”คa pattern including a digit character escape sequence should allow any digit character (๐Ÿงฒchar๐Ÿงฒ)๐Ÿ”ค
โ—
๐Ÿ‰
๐Ÿ”‚ char ๐ŸŽถ
๐Ÿ”คabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~๐Ÿ‘๐Ÿ‘ช,.-๐Ÿ”ค
โ— ๐Ÿ‡
โŽ๐Ÿ‘‡
๐Ÿ‘Œ๐Ÿ‘€regex ๐Ÿ”คaโŒโŒโšซc๐Ÿ”ค ๐Ÿ”คa๐Ÿงฒchar๐Ÿงฒc๐Ÿ”คโ—โ“
๐Ÿ”คa pattern including a digit character escape sequence should not allow a character not included in the class (๐Ÿงฒchar๐Ÿงฒ)๐Ÿ”ค
โ—
๐Ÿ‰
๐Ÿ’ญ TORTURE TEST
๐Ÿ”ค๐Ÿ‡he๐ŸคœโŒโŒ๐Ÿ”ก๐Ÿ‘โŒโŒ๐Ÿ”ข๐Ÿ‘โŒโŒ๐Ÿ‡๐Ÿค›๐Ÿ”˜o a๐Ÿคœcat๐Ÿ‘dog๐Ÿค›๐ŸบโŒโŒโšซ๐Ÿฌb๐ŸบR๐Ÿ”˜โŒโŒ๐Ÿ”กโŒโŒ๐Ÿ”ข๐ŸบโŒโŒ๐Ÿ‰๐Ÿฟ0123๐Ÿ†โšช๐Ÿ”˜AAA๐Ÿ‰๐Ÿ”ค โžก๏ธ pattern
๐Ÿ”คhe๐Ÿ‡0eo adogcatdogdog bbbbbbbbbbbbj009๐Ÿ‰2~~AAA๐Ÿ”ค โžก๏ธ string
๐Ÿ‘€regex pattern stringโ— โžก๏ธ result
โ›”๐Ÿ‘‡ ๐Ÿ‘Œresultโ“ ๐Ÿ”คtorture test pattern/input should match๐Ÿ”คโ—
๐Ÿ‰
๐Ÿ‰

EmojiRegex Syntax

Feature EmojiRegex Traditional Regex
Sets ๐ŸฟABC๐Ÿ† [ABC]
Alternates ๐ŸคœA๐Ÿ‘B๐Ÿค› A|B
Zero or More A๐Ÿ”˜ A*
One or More A๐Ÿบ A+
Zero or One (optional) A๐Ÿฌ A?
Any Character โšช .
Input Start ๐Ÿ‡ ^
Input End ๐Ÿ‰ $
Escaping โŒ \
any 'word' character โŒ๐Ÿ”ก \w
any 'digit' character โŒ๐Ÿ”ข \d
any 'whitespace' character โŒโšซ \s
@joeskeen
Copy link
Author

A HUGE thanks to "clumsy computer" on YouTube for his live-stream implementation of a regex engine in Python. I gained the understanding, coded along with him in TypeScript, got it working the way I wanted to, then translated it into EmojiCode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment