Click here to Skip to main content
Rate this: bad
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 21:49pm

1 solution

Rate this: bad
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"[^]).

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

  Print Answers RSS
0 OriginalGriff 375
1 Afzaal Ahmad Zeeshan 125
2 Zoltán Zörgő 120
3 DamithSL 100
4 Peter Leow 95
0 enhzflep 40
1 Richard Deeming 25
2 OriginalGriff 10
3 Anddos 10
4 Kornfeld Eliyahu Peter 10

Advertise | Privacy | Mobile
Web01 | 2.8.150224.1 | Last Updated 16 Oct 2012
Copyright © CodeProject, 1999-2015
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