homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

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 [b]¦¦[/b]:

<!--#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!

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved