Posted by Oli Filth on 02/27/06 21:13
Paul Renton said the following on 27/02/2006 16:53:
> What I'm trying to do is to pick out a starting tag and a finishing tag with
> anything in-between but the finishing tag. For example:
>
> {#my_tag}
> blah blah blah
> {/#my_tag}
>
> However, if there is another instance of this also on the page like:
>
> {#my_tag}
> blah blah blah
> {/#my_tag}
>
> -- Stuff --
>
> {#my_tag}
> blah blah blah
> {/#my_tag}
>
> I don't want the regex to use the start of the first block and the end of
> the second because that would cut out everything in between.
>
> So what I'm looking for is something similar to:
>
> {#tag_name}[anything that doesn't contain {/#tag_name}]{/#tag_name}
>
If you have a regex of the form:
STUFF.*STUFF
then any "STUFF"s in-between will get swallowed by the .*.
However, if you do:
STUFF.*?STUFF
then the * is made un-greedy, i.e. it swallows as little as possible.
--
Oli
Navigation:
[Reply to this message]
|