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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:43:16+00:00 2026-06-05T04:43:16+00:00

$string1 = This is test [example]; $string2 = This is test [example][2]; $string3 =

  • 0
$string1 = "This is test [example]";
$string2 = "This is test [example][2]";
$string3 = "This [is] test [example][3]";

How can I get the following result?

For $string1 -> example
For $string2 -> example*2
For $string3 -> is*example*3
  • 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-05T04:43:17+00:00Added an answer on June 5, 2026 at 4:43 am
    preg_match_all('/\[([^\]]+)\]/', $str, $matches);
    
    php > preg_match_all('/\[([^\]]+)\]/', 'This [is] test [example][3]', $matches);
    php > print_r($matches);
    Array
    (
        [0] => Array
            (
                [0] => [is]
                [1] => [example]
                [2] => [3]
            )
    
        [1] => Array
            (
                [0] => is
                [1] => example
                [2] => 3
            )
    
    )
    

    And here’s the explanation for the rregex:

    \[ # literal [
    ( # group start
        [^\]]+ # one or more non-] characters
    ) # group end
    \] # literal ]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can i remove $_SERVER['DOCUMENT_ROOT'] from a string like this /home/bla/test/pic/photo.jpg the result should
I have the following data: [{class:test,description:o hai,example:a,banana:b}] As this JSON data is already in
I have this method: public void testJSNI2(){ String x = test; } I can
I have the following string: This *is* a *test*! I want to bold the
I have a string like this: TEST.DATA.Data.COR.Point,2;TEST.DATA.Data.COR.Point,5;TEST.DATA.Data.COR.Point,12;TEST.DATA.Data.COR.Point,12;TEST.DATA.Data.COR.WordTOFIND,18 I have a list of array with
I have this string: Test: String And I want to select the text before
I have code like this: string uriString = @C:\Temp\test.html; Uri uri = new Uri(uriString);
So given this input string: =?ISO-8859-1?Q?TEST=2C_This_Is_A_Test_of_Some_Encoding=AE?= And this function: private string DecodeSubject(string input) {
I am loading a certificate from string like this: public static void Test() {
I have a String variable say strHTML = <div class='abc'> This is a test

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.