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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:05:11+00:00 2026-06-18T03:05:11+00:00

Good day. I’m having a problem with a pattern . Let’s assume I have

  • 0

Good day.

I’m having a problem with a pattern.

Let’s assume I have a string like this:

Hello [person]Name[/person], I don’t know regex like
[person]Another_name[/person] does.

I need to preg_split this string to get an array like this:

Array(0 => 'Name', 1 => 'Another_name');

I’ve been trying to solve this for some time and still no luck.

Pardon for my ignorance. Any kind of help is kindly appreciated.

  • 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-18T03:05:12+00:00Added an answer on June 18, 2026 at 3:05 am

    You’ll want to use something like preg_match_all instead of preg_split:

    preg_match_all("|\[person\](.*)\[/person\]|U",
        "Hello [person]Name[/person], I don't know regex like [person]Another_name[/person] does.",
        $out);
    
    echo $out[1][0] . ", " . $out[1][1] . "\n";
    

    You can learn more about how $out is structured here: http://www.php.net/manual/en/function.preg-match-all.php

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

Sidebar

Related Questions

Good day, I have a hibernate mapping which goes something like this <class name=Person>
Good Day all , I am having this problem since many days now ,
Good day, I have like 15 images I need to be buttons. I have
Good day! I have a quite strange problem. I have installed joomla on one
Good day!, I hope someone has the answer to this question. I'm having troubles
Good day. I have a problem with launching program in emulator. There is a
Good day code knights, I have a tricky problem that I cannot see a
Good day to all. I have the flowing problem. I have 2 domains. On
Good Day, I'm new to this Youtube GData api and i'm having trouble with
Good day. I'm working on a fps game, and I have a problem with

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.