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 6064579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:17:44+00:00 2026-05-23T09:17:44+00:00

Suppos that within a regex, if match one alternative from an alternation it stop

  • 0

Suppos that within a regex, if match one alternative from an alternation it stop right there even if still more alternatives left (there are no other tokens in the regex outside the alternation).

Source

This pattern that search one double word (e.g., this this)

\b([a-z]+)((?:\s|<[^>]+>)+)(\1\b)

I have one confusion if I introduce this subject:

It match with the patern.

"<i>whatever<i>         whatever"

\b([a-z]+) Match

((?:<[^>]+>|\s)+) Follows one TAG, so the 2nd alternative match.

(\1\b) Have to match if follows the same word backreferenced in the first parentheses.

Why match if after the tag not follows the ‘(\1\b)‘, follows whitespaces.

I know that within the alternation exist \s.

But is not supposed that the TAG match consume the alternation?

Why the \s alternative still alive?

  • 1 1 Answer
  • 0 Views
  • 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. Editorial Team
    Editorial Team
    2026-05-23T09:17:44+00:00Added an answer on May 23, 2026 at 9:17 am

    The alternation is controlled by a + quantifier:

    (?:\s|<[^>]+>)+
    

    …so it tries to match multiple times. Each time, it may try both alternatives: first \s, and if that fails, <[^>]+>.

    The first time, \s fails to match, but <[^>]+> succeeds in matching <i>.

    The second time, \s matches one space.

    The third time, \s matches another space.

    …and so on, until all the spaces are consumed.

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

Sidebar

Related Questions

Suppose that I have a Java program within an IDE (Eclipse in this case).
Suppose that two tables exist: users and groups . How does one provide simple
Suppose that there are 3 databases for Production Staging Dev As far as I
Suppose I was trying to match the following expression using regex.h in C++, and
Any efficient/reliable way to expose one event? I have a class, MultipleDocumentCopier that copies
background: i've noticed that for regular activities within, it is possible for any application
I am working on an PHP application that uses ajax to load components within
I am updating an activity's UI from a BroadcastReceiver that I register in the
I'm stuck on a RegEx problem that's seemingly very simple and yet I can't
Is there any elegant way to make Java method located within parent class return

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.