Solved

How do fix this Regex statement (Followup Question)

Posted on 2015-01-18
2
95 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Testing a string condition in PHP 6 22
mysql update statement 3 22
send post values 7 26
How can I implement a "Select All" with this configuration...? 6 39
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
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…

776 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