| Welcome to WebmasterWorld Guest from 188.8.131.52 |
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
|Subscribe to WebmasterWorld|
|Exact match regexp syntax for Apache SSI flow control|
pushing SSI to the limit and beyond
| 5:35 pm on May 21, 2003 (gmt 0)|
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.
| 6:45 pm on May 21, 2003 (gmt 0)|
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.
| 7:13 pm on May 21, 2003 (gmt 0)|
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.
© Webmaster World 1996-2013 all rights reserved