Click here to Skip to main content
12,296,307 members (64,216 online)
Rate this:
 
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
Top Experts
Last 24hrsThis month


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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100