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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:45:55+00:00 2026-05-18T09:45:55+00:00

I have this regex: (?:\S)\++(?:\S) Which is supposed to catch all the pluses in

  • 0

I have this regex:

(?:\S)\++(?:\S)

Which is supposed to catch all the pluses in a query string like this:

?busca=tenis+nike+categoria:"Tenis+e+Squash"&pagina=4&operador=or

It should have been 4 matches, but there are only 3:
s+n
e+c
s+e

It is missing the last one:
e+S

And it seems to happen because the “e” character has participated in a previous match (s+e), because the “e” character is right in the middle of two pluses (Teni s+e+S quash).

If you test the regex with the following input, it matches the last “+”:

?busca=tenis+nike+categoria:"Tenis_e+Squash"&pagina=4&operador=or

(changed “s+e” for “s_e” in order not to cause the “e” character to participate in the match).

Would someone please shed a light on that?

Thanks in advance!

  • 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-18T09:45:56+00:00Added an answer on May 18, 2026 at 9:45 am

    You are correct: The fourth match doesn’t happen because the surrounding character has already participated in the previous match. The solution is to use lookaround (if your regex implementation supports it – JavaScript doesn’t support lookbehind, for example).

    Try

    (?<!\s)\++(?!\s)
    

    This matches one or more + unless they are surrounded by whitespace. This also works if the plus is at the start or the end of the string.

    Explanation:

    (?<!\s)  # assert that there is no space before the current position
             # (but don't make that character a part of the match itself)
    \++      # match one or more pluses
    (?!\s)   # assert that there is no space after the current position
    

    If your regex implementation doesn’t support lookbehind, you could also use

    \S\++(?!\s)
    

    That way, your match would contain the character before the plus, but not after it, and therefore there will be no overlapping matches (Thanks Gumbo!). This will fail to match a plus at the start of the string, though (because the \S does need to match a character). But this is probably not a problem.

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

Sidebar

Related Questions

I have this python script which is supposed to wrap all that look like
I have this regex: /\*([^<|\n|\r]+)/ which matches all characters in a string starting with
Is this Regex correct if I have to match a string which is atleast
Hi have this URL string which I need to extract possibly using regex but
I have this HTML string which often has a lot of whitespaces Example: <p>All
I have this regex (?<=L).+?(?=;) Which is supposed to match anything between L and
I have this regex which is supposed to remove sentence delimiters( . and ?
I have this regex: private static final String SPACE_PATH_REGEX =[a-z|A-Z|0-9|\\/|\\-|\\_|\\+]+; I check if my
Here is an easy one :) on REGEX I have this regex ^\\$?(\\d{1,3},?(\\d{3},?)*\\d{3}(\\.\\d{2})?|\\d{1,3}(\\.\\d{2})?|\\.\\d{2}?)$ which
I have this regex variable: var regexp = new RegExp(RegExp.quote(myExpression) + '\\b', 'g'); which

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.