Skip to content

Commit c648bca

Browse files
authored
Merge pull request #5337 from DmitryOlshansky/uni-regex-charset
Add public API for regex charset parser merged-on-behalf-of: Sebastian Wilzbach <sebi.wilzbach@gmail.com>
2 parents f5e80f1 + 5d0c5db commit c648bca

File tree

4 files changed

+765
-696
lines changed

4 files changed

+765
-696
lines changed

std/regex/internal/ir.d

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -47,40 +47,11 @@ CharMatcher[CodepointSet] matcherCache;
4747
}
4848
}
4949

50-
@trusted auto memoizeExpr(string expr)()
51-
{
52-
if (__ctfe)
53-
return mixin(expr);
54-
alias T = typeof(mixin(expr));
55-
static T slot;
56-
static bool initialized;
57-
if (!initialized)
58-
{
59-
slot = mixin(expr);
60-
initialized = true;
61-
}
62-
return slot;
63-
}
64-
65-
//property for \w character class
66-
@property CodepointSet wordCharacter()
67-
{
68-
return memoizeExpr!("unicode.Alphabetic | unicode.Mn | unicode.Mc
69-
| unicode.Me | unicode.Nd | unicode.Pc")();
70-
}
71-
72-
@property CharMatcher wordMatcher()
73-
{
74-
return memoizeExpr!("CharMatcher(wordCharacter)")();
75-
}
50+
static CharMatcher wordMatcher = CharMatcher(wordCharacter);
7651

7752
// some special Unicode white space characters
7853
private enum NEL = '\u0085', LS = '\u2028', PS = '\u2029';
7954

80-
// Characters that need escaping in string posed as regular expressions
81-
alias Escapables = AliasSeq!('[', ']', '\\', '^', '$', '.', '|', '?', ',', '-',
82-
';', ':', '#', '&', '%', '/', '<', '>', '`', '*', '+', '(', ')', '{', '}', '~');
83-
8455
//Regular expression engine/parser options:
8556
// global - search all nonoverlapping matches in input
8657
// casefold - case insensitive matching, do casefolding on match in unicode mode

0 commit comments

Comments
 (0)