Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 75779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:34:11+00:00 2026-05-10T20:34:11+00:00

Using ICU 4.0 regex library, I find that the following regex is exhibiting exponential

  • 0

Using ICU 4.0 regex library, I find that the following regex is exhibiting exponential time:

actual: '[^<]*<\?' C code: '[^<]*<\\?' 

Aim: find ‘<?’ where there is no other ‘<‘ before it

When running this regex on plain text with no ‘<‘ characters at all it appears to take exponential time. If the text has at least a single ‘<‘ then it is quick. I don’t understand why.

Shouldn’t the required match on ‘<?’ prevent this from needing to backtrack? I would have thought that it would try to find the first ‘<‘ and then test the rest of the expression. If it can’t find a ‘<‘ then it would give up because the pattern obviously can’t match.

Is this a bug in the ICU regex or is it expected?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T20:34:11+00:00Added an answer on May 10, 2026 at 8:34 pm

    You will find an explanation at Regular Expression Matching Can Be Simple And Fast.
    As MizardX said, if the match fails at position 0, the engine will try again at position 1, 2, etc. If the text is long, be ready to wait for quite some time…

    The solution is to anchor your expression: '^[^<]*<\?'

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the wonderful RegexKitLite framework built upon the ICU library that ships with
I am using the ICU library in C++ on OS X. All of my
While attempting to cross-compile ICU using android-ndk-r7 in Linux, the following error occurs after
I am using a C++ third party library that places all of its classes
Is it possible to custom format currency strings using the ICU library similar to
I could get a set of ICompilationUnit using the following code, but I need
In attempting to compile ICU49 using Android NDKv7b, I ran into the following: /home/tim/icu49/icu/source/common/putil.cpp:
I'm currently using the ICU library to handle Unicode data, and am trying to
The tooltips can be set to display percentages using the following code: var formatter
Hi i am using Standard Regex Library (regcomp, regexec..). But now on demand i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.