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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:21:10+00:00 2026-06-06T20:21:10+00:00

I have data in format: Randomtext1 (random2,random4) Randomtext2 (ran dom) Randomtext3 Randomtext4 (random5,random7,random8) So

  • 0

I have data in format:
Randomtext1 (random2,random4) Randomtext2 (ran dom) Randomtext3 Randomtext4 (random5,random7,random8)

So I would like to recognize the both the Randomtext-part and the text with in brackets, if it is there with preg_match_all, but im not sure how to get it done. The stuff in the brackets goes together with the Randomtext-part and some of the Randomtext-parts have it and some of them dont.

This is what I have so far, and it works in most cases, but if the text doesnt have any brackets, then it matches the whole thing to one.

preg_match_all("/([a-zA-Z]+)\s+(?([a-zA-Z, ]*))?/",$text,$matches);

Any ideas?

  • 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-06T20:21:14+00:00Added an answer on June 6, 2026 at 8:21 pm
    preg_match_all("/\b\w+\b(?:\s*\(.*?\)|)/", $text, $matches);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say you have data in the format: name=john;age=33;gender=male What would you call a method
I have this xml data format. I would like to extract the properties name
In controller code, I have data in json format data = { 1: {assetId:1,status:true},
I have data in this format coming from a database... BUS 101S Business and
I have data in the following format: 4:How do you do? 10:Happy birthday 1:Purple
I have some data in the format of C222 = 50 C1234P687 = 'some
I have data that is organized in kind of a key-key format, rather than
I have a XML file with the following data format: <net NetName=abc attr1=123 attr2=234
I have a data.frame df in format long. df <- data.frame(site = rep(c(A,B,C), 1,
I have a data with the following format: foo<tab>1.00<space>1.33<space>2.00<tab>3 Now I tried to sort

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.