Jump to content

[RESOLVED] StringRegExp only returns first match


Recommended Posts

Hi,

I have the following code:

Func _getFood($day,$time)
    $days = StringRegExp($matches1,"<tr>.*?</tr>",1)
    _ArrayDisplay($days)
EndFunc

The value of $matches1 is:

<table id='menu'><tr><td></td><th>Sunday</th><th>Monday</th><th>Tuesday</th><th>Wednesday</th><th>Thursday</th><th>Friday</th><th>Saturday</th></tr><tr><th>Breakfast</th><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><th>Brunch</th><td>Sunday brunch</td><td></td><td></td><td></td><td></td><td></td><td>Brunch</td></tr><tr><th>Lunch</th><td></td><td>Pork chop, orange & gingerYYYXXXMoroccan vegetable tangine with cous-cous</td><td>Breaded turkey, lemon & caper butterYYYXXXChinese style stuffed peppers</td><td>Smoked fish dauphinoiseYYYXXXLeek & red leicester with herb scone</td><td>Oriental chickenYYYXXXTagliatelle, broccoli & mushroom sauce</td><td>Salmon wrapped in filo with tapenadeYYYXXXNut roast</td><td></td></tr><tr><th>Dinner</th><td></td><td>Spaghetti bolognaiseYYYXXXTomato, goats cheese & basil tart</td><td><font color="red">Curry night</font></td><td><font color="red">Burger night</font></td><td>Yet another...<BR><font color="blue">Formal hall</font></td><td>Chicken risottoYYYXXXPolenta & roasted vegetables</td><td></td></tr><tr><th>Notes</th><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>

Hence the Regexp should (in theory) return several matches - each complete <tr></tr> "bracket".

However, for some reason, it only ever returns the first result.

I have no idea why - can anyone help me on this?

Running StringRegExpReplace with the same regular expression worked fine - all the <tr></tr> tags with content were replaced.

But StringRegExp doesn't work...

Thanks,

--WhiteAvenger

Edited by WhiteAvenger
Link to comment
Share on other sites

That after there is an overall match (which is the most preferred result) the not global stop and return a result if there is one. The global capture it but continue with the rest of the string until the end of the string has been reached, thus may report multiple matches.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...