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

  • Home
  • SEARCH
  • 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 3848424
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:41:58+00:00 2026-05-19T16:41:58+00:00

I currently have this: ^(.+)\(\w+\)|^(.+)\s\(\d{3}\:\d{3}\s\-\s\d{3}\:\d{3}\) The #1 it only matches Foo’s #2 Foo has

  • 0

I currently have this:

^(.+)\(\w+\)|^(.+)\s\(\d{3}\:\d{3}\s\-\s\d{3}\:\d{3}\)

The #1 it only matches Foo’s
#2 Foo has which is correct
#3 does match foo but it’s in the 3rd array item [2]:

3rd array output:
    (
        [0] => Foo (100:200 - 300:400)
        [1] => 
        [2] => Foo
    ) 

The bold is what I’m trying to match:
Foo’s (match11) this (100:200 – 300:400) the end #1
Foo has (not_matched) (100:200 – 300:400) the end #2
Foo (100:200 – 300:400) the end #3
note: im not trying to match the #1,#2,#3 at the end of each line, thats just for reference.

If “(100:200 – 300:400)” is found then get any text in front of it, elseif “(not_matched) (100:200 – 300:400)” found then get any text in front of it, else get text in front of “(100:200 – 300:400)”

The elseif part “(not_matched) (100:200 – 300:400)” can be identified as it only has 1 white space between the 2 round brackets of not_matched and (100:200 – 300:400)

Edit:

This is what i’v come up with which does seem to work, though it requires some workarounds in php to be useful.

(.+)\s\(\w+\)\s\(|(.+)\s\(\d{3}\:\d{3}\s\-\s\d{3}\:\d{3}\)

Working example: http://www.rubular.com/r/NSpGcnyg0p
For some reason it doesn’t seem to save my example, so you will have to copy/paste it in.

But the regex doesn’t have a direct match on each of them, thats why I have to remove the empty array element in php so that I get the result in the [1] element.

Can anyone see what I’m doing wrong in my regex?

  • 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-19T16:41:59+00:00Added an answer on May 19, 2026 at 4:41 pm

    Try this:

    ^.*?(?=\s*(?:\(not_matched\)\s)?\(\d+:\d+\s*-\s*\d+:\d+\))
    

    or, in PHP:

    if (preg_match(
        '/^                   # Anchor the match at start of line
        .*?                   # Match any number of characters lazily
        (?=                   # until just before the following:
         \s*                  # - optional whitespace
         (?:                  # - the following group:
          \(not_matched\)\s   #    - literal (not_matched), followed by 1 whitespace
         )?                   #   (which is optional)
         \(\d+:\d+\s*-\s*\d+:\d+\) # a group like (nnn:mmm - ooo:ppp)
        )                     # End of lookahead assertion
        /x', 
        $subject, $regs)) {
        $result = $regs[0];
    } else {
        $result = "";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We currently have code like this: Dim xDoc = XDocument.Load(myXMLFilePath) The only way we
I currently have this working but it requires me to have a static method
I do not currently have this issue , but you never know, and thought
I need a regular expression that matches APA format references. I currently have this:
I have this little code which lists all matches of items that contains the
How would I create a nested list, I currently have this public function getNav($cat,$subcat){
Currently i have this method: static boolean checkDecimalPlaces(double d, int decimalPlaces){ if (d==0) return
Currently i have this: $(.splitCol).click(function () { $.cookie('whichColumn', 'split'); $(.threeCol .active).removeClass(active); $(.leftCol .active).removeClass(active); $(.splitCol
Note: I'm using Google Chrome Currently I have this test page http://www.evecakes.com/doodles/canvas_size_issue.htm It should
Using dotnet 2.0. I currently have code like this : DataView dv = new

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.