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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:40:16+00:00 2026-06-15T23:40:16+00:00

Building on this question: Regular expression to extract text between square brackets this is

  • 0

Building on this question: Regular expression to extract text between square brackets

this is a [sample] string with [some] special words. [another one]

I need to extract the text between [sample] and [some] plus the two boundaries too. In other word I want the regex that matches [sample] string with [some]

  • 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-15T23:40:17+00:00Added an answer on June 15, 2026 at 11:40 pm

    Try this:

    /\[sample\].*?\[some\]/
    

    You just need to escape the square brackets and use a lazy match between your markers.

    See it here on Regexr.

    If the text can be on several rows, you need to enable the dotall mode additionally with the s modifier:

    /\[sample\].*?\[some\]/s
    

    this makes the . also match newline characters, what it is not doing by default.

    See it here on Regexr

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

Sidebar

Related Questions

Building on this question: Django Celery Time Limit Exceeded? I have some tasks that
Unlike this question: Linker Error while building application using Boost Asio in Visual Studio
I'm building a hub which should send message to specific user and this Question
Sorry for such a trivial question, but I'd feel silly building this if it
I am building a web application (in Django, though this isn't a Django-specific question).
This question is asked because the author is building a compiler (src -> asm)
Building on Tony's answer on this question : If I want to do something
As a follow on from this question I'm building a custom server control to
This is a followup of this question. Where I was building a google apps
This is more of a logic question than a coding question. I am building

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.