Click here to Skip to main content
15,889,462 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have a piece of code that will try to extract URLs (through the use of regexs) from a piece of text. My code works fine when the text is small, however, when having a very large text, the boost::regex_search function takes almost 1 minute to complete.

This is way too much executing time because on other texts, the boost::regex_search takes 2 milliseconds at most, which is my scenario is acceptable. However, 1 minute is definitely too much.

As such, I need to find a way how to stop the function boost::regex_search after a few milliseconds. Is this even possible? Are there other solutions to this? I don't want to change the regex expression because it has always worked correctly and efficiently. Also this problem is a one off.

Thanks for your time and any suggestions are greatly welcome.
Posted

1 solution

I think blocking the function is not an option (or at least a good option). You should find the flaw in your expression (regular expressions do have pitfalls, see, for instance "Runaway Regular Expressions: Catastrophic Backtracking"[^]).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900