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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:25:30+00:00 2026-06-06T10:25:30+00:00

So basically I have this giant regular expression pattern, and somewhere in the middle

  • 0

So basically I have this giant regular expression pattern, and somewhere in the middle of it is the expression (?:\s(\d\d\d)|(\d\d\d\d)). At this part of the parse I’m wanting to capture either 3 digits that follows a space or 4 digits, but I don’t want the capture that comes from using the parenthesis around the whole thing (doesn’t ?: make something non-capture). I have to use parenthesis so that the “or” logic works (I think).

So potential example inputs would be something like…

  • input1= giantexpression 123more characters after
  • input2= giantexpression1234blahblahblah

I tried (?:\s(\d\d\d)|(\d\d\d\d)) and it gave an extra capture at least in the case where I have 4 digits. So am I doing this right or am I messed up somewhere?

Edit:

To go into more detail… here’s the current regular expression I’m working with.

pattern = @".?(\d{1,2})\s*(\w{2}).?.?.?(?:\s(\d\d\d)|(\d\d\d\d)).*"

There’s a bit of parsing I have to do at the beginning. I think Sean Johnson’s answer would still work because I wouldn’t need to use “or”. But is there a way to do it in which you DO use “or”? I think eventually I’ll need that capability.

  • 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-06-06T10:25:35+00:00Added an answer on June 6, 2026 at 10:25 am

    This should work:

    (?:\s(\d{3,4}))
    

    If you aren’t doing any logic on that subpattern, you don’t even need the parenthesis surrounding it if all you want to do is capture the digits. The following pattern:

    \s(\d{3,4})
    

    will capture three or four digits directly following a space character.

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

Sidebar

Related Questions

Ok, so basically I have this part of the .htaccess partly working, but not
I have this error that is keeping me from moving forward. I basically have
Basically I have this string for example $str = 'По, своей 12' I need
Basically I have this string $str=word1 word2 word3; I need array( 'word1', 'word2', 'word3'
I have (basically) this code - <script type=text/javascript language=javascript> $(document).ready(function() { $(#loadDiv).load(mypage.html, function(){ alert($(#someText).text())
I have this type which is basically a struct { int x,y,z; } that
I have this script which basically toggles a bgColor class on and off so
I have this grand idea to basically employ some brute force attack to test/verify
Basically what I have is this: secondData = [[8:33:00, 5], [8:33:01, 3], ...] #
I basically have this piece of code. char (* text)[1][80]; text = calloc(2821522,80); The

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.