Solved

How do fix this Regex statement (Followup Question)

Posted on 2015-01-18
2
93 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
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
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 a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

706 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now