Battling Greedy Regular Expressions in Keyword Replacement

Hi all,


I have this bit of code in a design file:



<MySource_AREA id_name="menu" design_area="menu_normal">

<MySource_SET name="level" value="top" />

<MySource_ASSET>

<li><a href="<MySource_PRINT var="asset_link" />"><i><MySource_PRINT var="asset_short_name^maxwords:1" /></i> <MySource_PRINT var="asset_short_name^replace:[a-zA-Z]+? :" /></li>

</MySource_ASSET>

</MySource_AREA>



Which is returning this in a page:



<li><a href="http://matrixdemo.squiz.net/the-weblogue"><i>The </i> Weblogue</li>

<li><a href="http://matrixdemo.squiz.net/back-issues"><i>Back </i> Issues</li>

<li><a href="http://matrixdemo.squiz.net/about-our-paper"><i>About </i> Paper</li>



The asset_short_name for the last item is 'About Our Paper'. The replace regular expression appears to be greedy, giving me '<i>About </i> Paper</li>' instead of the desired '<i>About </i> Our Paper</li>'. Is there any way I can make the match lazy? What sort of regular expression operators are supported?



Cheers,

Iestyn.

Ok I've got what I needed this time, by using:


<MySource_PRINT var="asset_short_name^replace:[0-9A-Za-z]+ ([0-9A-Za-z ]*):$1" />



I think it would be good if there was a section linked from the keyword replacement page of the squiz manual that listed the various regular expression operators that were available.



HTH



Cheers,

Iestyn.

I've actually not used regexps in Squiz yet, but I do recall reading that Squiz uses the normal PCRE syntax which is fairly ubiquitous; I'm used to it from PHP… http://www.php.net/manual/en/book.pcre.php