Mike Bresnahan wrote:

>I have a perl/regular-expression question.  I want to match lines in a web
>server log file based on multiple URL parameters.  The X parameters may come
>in any order.  The order is unimportant to me.  Can I express this in a
>regular expression?  Something like the following would make sense, but I
>don't see a logical AND in the docs, only a logical OR.
>
>(foo)&(bar)&(beef)
>
>This would match all of the following:
>
>foo=423&bar=234&beef=234
>bar=423&beef=234&foo=2423
>bar=2342&foo=234&beef=234234
>
>Note that I have a need to express this in a single regular expression.
>
>Mike Bresnahan
>
If you have a fixed number of URLs on a line, and just want to make sure 
that they contain all the ones you want, you can do:

if( $foo =~ m/[123][123][123]/ )  // Will match if 1, 2, or 3 are 
present 3 times

If you're just talking about seeing if one of the URLs you're matching 
against is present in a given line, you'd do it like this:

if( $foo =~ m/[123]/ ) // Will match if 1, 2, or 3 are present anywhere 
in $foo

Hard to get more specific without knowing what the data format is.

As for logical AND, it's '&&':
if( ($foo == 1) && ($bar == 2) )
{ // Do stuff }

Michael Vieths
Foeclan at Visi.com


_______________________________________________
tclug-devel mailing list
tclug-devel at mn-linux.org
https://mailman.real-time.com/mailman/listinfo/tclug-devel