| Welcome to WebmasterWorld Guest from 18.104.22.168 |
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
|Pubcon Platinum Sponsor 2014|
|Exact match regexp syntax for Apache SSI flow control|
pushing SSI to the limit and beyond
How do I get a statement like the below to do exact matches?
<!--#if expr="$variable = /foo¦bar¦sna/" -->
As written, it matches words like "food" & "snack".
I realize I could split it up into 3 non-regular expression conditional statements ($variable=foo ¦¦ $variable=bar, etc.), but I'd like to keep it together for elegance and maintainability.
As far as I can tell, you have two possibilities.
When using a regex, then you need to anchor your pattern to the start and the end of the string:
<!--#if expr="$variable = /[b]^[/b](foo¦bar¦sna)[b]$[/b]/" -->
Alternatively, you could use the or operator, which is written as
<!--#if expr="$variable = foo [b]¦¦[/b] $variable = bar [b]¦¦[/b] $variable = sna" -->
I haven't actually tested either variation, but they should at least give you a start into the right direction.
Hey Bird, I think that's exactly the tip I was looking for.
For my application I'm going to use the following to get an exact match on "foo" and substring matches for the rest.
<!--#if expr="$QUERY_STRING = /^foo$¦bar¦sna/" -->
Thanks for getting me pointed in the right direction!
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved