Skip to content

Instantly share code, notes, and snippets.

@jershmagersh
Last active December 23, 2015 10:09
Show Gist options
  • Save jershmagersh/6619260 to your computer and use it in GitHub Desktop.
Save jershmagersh/6619260 to your computer and use it in GitHub Desktop.
Search regex construction
if(this->rules->size() > 0) {
string searchBlock = "";
for(rulesIter = this->rules->begin(); rulesIter != this->rules->end(); rulesIter++) {
if(rulesIter == this->rules->begin()) //Construct a big fat regex from all of the rules.
searchBlock += ".*(" + rulesIter->first + ").*";
else searchBlock += "|.*(" + rulesIter->first + ").*";
}
this->globalMatchBlock = new regex(searchBlock);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment