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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:38:09+00:00 2026-05-20T20:38:09+00:00

I really don’t understand regex at all, and it hurts my head. I’ve a

  • 0

I really don’t understand regex at all, and it hurts my head.

I’ve a bit of text which looks like this

blah blah blah (here is the bit I'd like to extract)

…and I don’t really understand how to extract this using PHP’s preg_split, or equivalent, command.

How do I do this? And where’s a good place to understand how preg works?

  • 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-20T20:38:10+00:00Added an answer on May 20, 2026 at 8:38 pm

    Something like this should do the trick, to match what is between ( and ) :

    $str = "blah blah blah (here is the bit I'd like to extract)";
    if (preg_match('/\(([^\)]+)\)/', $str, $matches)) {
        var_dump($matches[1]);
    }
    

    And you’d get :

    string 'here is the bit I'd like to extract' (length=35)
    

    Basically, the pattern I used searches for :

    • An opening ( ; but as ( has a special meaning, it has to be escaped : \(
    • One or more characters that are not a closing parenthesis : [^\)]+
      • This being captured, so we can use it later : ([^\)]+)
      • And this first (and only, here) captured thing will be available as $matches[1]
    • A closing ) ; here, too, it’s a special character that has to be escaped : \)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I really don't understand Javascript. In PHP, I can remove quotes like this: $tags_array
I really don't know enough about regex to tackle this on my own so...
I really don't understand this. I have a simple ASP with 3 div in
I really don't understand what I'm doing wrong, but according to Adobe, this is
I really don't like this style of formatting: Class AwesomeClass { private static void
This is a bit complex and I really don't now if it is possible.
I have this json object (which i don't really know what is inside) and
I really don't understand why this function doesn't work: function GetNomRepertoireTemporaire:WideString; var PathLocal :
I really don't understand how a class like HttpContext.Current is visible (for the single
I use this code to get Server Date but I really don't understand.CreateDateTime() is

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.