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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:58:03+00:00 2026-05-11T17:58:03+00:00

I am attempting to extract all instances of a particular format from a string:

  • 0

I am attempting to extract all instances of a particular format from a string:

I am wondering if my new Sony [PT# 123456ABC; Sony] has this feature but my friend says the new Toshiba [PT# AD-3232hjk; Toshiba] has this feature.

I would like to extract:

[PT# 123456ABC; Sony]

[PT# AD-3232hjk; Toshiba]

As you can see here, the only items in the consistent positions are:

  • [PT#
  • ;
  • ]

I was attempting to use various types of strpos() but because of the varying lengths and formats of the part numbers and manufacturer names I was unable to reliably pull out those instances from a much larger string. I have been trying various ways to use regular expressions to solve this however my knowledge with them is fairly limited. After I have these expressions extracted and placed into variables I will then need to separate the part numbers and manufacturer names from the expression. This may also be easier to accomplish using regular expressions.

Any help is appreciated.
Thanks

  • 1 1 Answer
  • 1 View
  • 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-11T17:58:03+00:00Added an answer on May 11, 2026 at 5:58 pm

    I think this would do it

    preg_match_all( "/(\[PT#\s+.*?;\s+.*?\])/", $input, $matches );
    
    print_r( $matches );
    

    Altternatively, if you just wanted to capture the unique information

    preg_match_all( "/\[PT#\s+(.*?);\s+(.*?)\]/", $input, $matches );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just found a weird behavior when attempting to extract a string from the
I'm attempting to extract urls from a string, they aren't standardized so some are
I am attempting to extract all data from a file with one regex expression.
Attempting to use the data series from this example no longer passes the JSONLint
I'm attempting to parse XML in the following format (from the European Central Bank
Actually I am attempting to extract the data from a PDF file but I
I am attempting to extract a fundamental frequency from a sound source. maybe someone
I have a DateTime column. I want to extract all records, lets say, from
I'm attempting to run preg_match to extract the SRC attribute from the first IMG
I'm attempting to write an application to extract properties and code from proprietary IDE

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.