1

How can I evaluate time complexity of matching a regex using boost?

Does it only depend on the length and the recurrency or is anything else involved?

For example, let's assume I do have this regex that matches any alphanumeric string

[A-Za-z0-9]+

and I have a function like this

bool isAlphanumerical(string str){
  return boost::regex_match(str, "[A-Za-z0-9]+");
}

is there a way to tell what's its time complexity? what about if I add some cases like this (I also changed the former regex in order to only match combinations of numbers and capital letters ) :

[A-Z0-9]+$|\s*$|_*$

so that I can also match strings only containing spaces or hypens?

And what if I also recur over the pattern like this

(?i)[A-Z0-9]+$|\s*$|_*$

?

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
Elle
  • 305
  • 2
  • 10

0 Answers0