Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ Boost
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 15-Oct-12 20:49pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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"[^]).
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 330
1 Maciej Los 180
2 Richard MacCutchan 115
3 arvind mepani 104
4 Tino Fourie 92


Advertise | Privacy | Mobile
Web01 | 2.8.140709.1 | Last Updated 16 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid