Welcome to WebmasterWorld Guest from 54.163.168.15

Forum Moderators: Ocean10000 & incrediBILL & phranque

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)

10+ Year Member



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)

WebmasterWorld Senior Member 10+ Year Member



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)

10+ Year Member



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!

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month