?
Solved

How do fix this Regex statement (Followup Question)

Posted on 2015-01-18
2
Medium Priority
?
99 Views
Last Modified: 2015-01-28
How do I fix the last section of this regex?  The first two work (Pro Audio & Audio Recording), the last section (Drum Machines/Samplers)  does not.


<span class="head2"><strong><a href="category/pro-audio/1"><span class="head2">Pro Audio</span></a> </strong></span><strong> <span class="head3">&gt;</span> <a href="category/pro-audio/audio-recording/1">Audio Recording</a>
												&gt; <a href="products/pro-audio/audio-recording/drum-machines-samplers/1">Drum Machines/Samplers</a> </span>

Open in new window



This part works...   Need to add this part:
&gt; <a href="products/pro-audio/audio-recording/drum-machines-samplers/1">Drum Machines/Samplers</a> </span>

preg_match('%<span class="head2"><strong><a href="category/.*?/1"><span class="head2">(.*?)</span></a>\s*</strong></span><strong>\s<span class="head3">&gt;</span>\s<a href="category/.*?/.*?/1">(.*?)</a>(?:\s+\&gt;\s<a href="products/.*?/.*?/.*?/1">(.*?)</a> </span>\s+\&gt;\s(.*?)\s+</span>\s+</strong>\s+</td>)?
                                          %si',$buffer4,$matches4);

$a=$matches4[1];
$b=$matches4[2];
$c=$matches4[3];

Open in new window


Prior related question: http:Q_28599127.html
0
Comment
Question by:lawrence_dev
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 2000 total points
ID: 40557036
$buffer4='<span class="head2"><strong><a href="category/pro-audio/1"><span class="head2">Pro Audio</span></a> </strong></span><strong> <span class="head3">&gt;</span> <a href="category/pro-audio/audio-recording/1">Audio Recording</a>
                                                                                                                                                                                                  &gt; <a href="products/pro-audio/audio-recording/drum-machines-samplers/1">Drum Machines/Samplers</a> </span>
                                  ';
preg_match('%<span class="head2"><strong><a href="category/.*?/1"><span class="head2">(.*?)</span></a>\s*</strong></span><strong>\s<span class="head3">&gt;</span>\s<a href="category/.*?/.*?/1">(.*?)</a>\s+\&gt;\s<a href="products/.*?/.*?/.*?/1">(.*?)</a>%si',$buffer4,$matches4);
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to implement server side field validation and display customized error messages to the client.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question