File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -745,7 +745,11 @@ string genregex(string exp)
745
745
case ' [' :
746
746
{
747
747
set<char > possible;
748
- bool escaped = false ;
748
+ bool escaped = false , inverted = false ;
749
+ if ( i + 1 < exp.length () && exp[i+1 ] == ' ^' ) {
750
+ inverted = true ;
751
+ i++;
752
+ }
749
753
while (i + 1 < exp.length ()) {
750
754
i++;
751
755
if (escaped) {
@@ -773,7 +777,13 @@ string genregex(string exp)
773
777
}
774
778
}
775
779
vector<char > possibleVec;
776
- copy (possible.begin (), possible.end (), std::back_inserter (possibleVec));
780
+ if ( inverted ) {
781
+ for (char c = ' ' ; c <= ' ~' ; c++) {
782
+ if ( !possible.count (c) ) possibleVec.push_back (c);
783
+ }
784
+ } else {
785
+ copy (possible.begin (), possible.end (), std::back_inserter (possibleVec));
786
+ }
777
787
int mult = getmult (exp, i);
778
788
for (int cnt = 0 ; cnt < mult; cnt++) {
779
789
res += possibleVec[random () % possibleVec.size ()];
You can’t perform that action at this time.
0 commit comments