File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -745,7 +745,11 @@ string genregex(string exp)
745745 case ' [' :
746746 {
747747 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+ }
749753 while (i + 1 < exp.length ()) {
750754 i++;
751755 if (escaped) {
@@ -773,7 +777,13 @@ string genregex(string exp)
773777 }
774778 }
775779 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+ }
777787 int mult = getmult (exp, i);
778788 for (int cnt = 0 ; cnt < mult; cnt++) {
779789 res += possibleVec[random () % possibleVec.size ()];
You can’t perform that action at this time.
0 commit comments