PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Dec 22, 2014 9:10 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue Aug 11, 2009 2:19 am 
Offline
Forum Newbie

Joined: Tue Jul 28, 2009 7:16 pm
Posts: 3
The regex:
Syntax: [ Download ] [ Hide ]
 
# Region
<tr>
\s*<td\s+class="grey11">Region:</td>\s*
<td\s+class="b11\s+b">(?<Region>.+?(?=</td>))</td>
\s*
</tr>
\s*
 
</table>
\s*
 
#Optional AD
(
<div\s+class="wid342\s+fl\s+padtop15">
\s*
<div\s+class="linkicon\s+listicon\s+lh16">
\s*
<a(?:[^>]*?)>
(?:.+?)</a>\s*</div>\s*</div>
){0,1}
 
</div>
\s*
 
(
# Amenities
<div\s+class="wid342\s+fl\s+mtop10(?:[^>]*?)>
\s*
<div\s+class="
pad10">
(?:.+?)
<ul\s+class="
chkbox">
(?<Amenities>.+?)
</ul>
\s*
</div>
){0,1}
 
 
 
(?:.+?)
 
#Extra
(
<div\s+class="
b10\s+lh16\s+vpad10">
\s*(?<Extra>.+?)\s*
</div>
){0,1}
 
 



The text to be parsed:


Quote:
<tr>
<td class="grey11">Drive</td>
<td class="b11">Front</td>
</tr>
<tr>
<td class="grey11">Transm</td>
<td class="b11 b">Mech</td>
</tr>
<tr>
<td class="grey11">Intr</td>
<td class="b11">Leather</td>
</tr>

<tr>
<td class="grey11">COND:</td>
<td class="b11">USED</td>
</tr>
<tr>
<td class="grey11">Region:</td>
<td class="b11 b">QQQQQQQQQQQQQ</td>
</tr>
</table>
</div>
<div class="wid342 fl mtop10" style="background:#F5F5F5">
<div class="pad10">
<h4 class="darkred">What's inside</h4>
<ul class="chkbox">
<li class="par">
<ul>
<li>ABS</li>
<li>Acs</li>
<li>HUD</li>
<li>Immo</li>
</li>
<li class="par">
<ul>
<li>Chairs</li>
<li>Alarm</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="wid342 fl oh">
<p class="vmargin10">
<h4>Extra info</h4>
<div class="b10 lh16 vpad10">
Good condition. Assembled in ---------
</div>





Why doesn't it return me "Good condition. Assembled in ---------" for "Extra" group? This group is actually optional; that's why I marked it with {0,1}. And if I remove {0,1} the regex returns me it's expected value but only in this particular case.

What's wrong to my regex?


Top
 Profile  
 
PostPosted: Tue Aug 11, 2009 2:56 am 
Offline
Forum Regular
User avatar

Joined: Fri Apr 04, 2008 5:51 am
Posts: 779
What is wrong with you? The previous time you posted a question, you didn't post any follow up to mention whether my reply was helpful or not (let alone post a proper "thank you"). You also posted the same question in various other regex forums without mentioning this. I explained to you that because of this, it is likely that other people are duplicating their answers because these answers have already been given in an other forum. You are then in effect, wasting other people's time. Yet you simply continue cross posting!

I'm done helping your kind.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group