From kschnitker at mn.rr.com Tue Dec 2 18:56:44 2003 From: kschnitker at mn.rr.com (Ken Schnitker) Date: Mon Jan 17 14:29:08 2005 Subject: [TCLUG-DEVEL] Contractor Message-ID: <200312030054.hB30sfsh025344@ms-smtp-03.rdc-kc.rr.com> Skipped content of type multipart/alternative-------------- next part -------------- _______________________________________________ tclug-devel mailing list tclug-devel@mn-linux.org https://mailman.real-time.com/mailman/listinfo/tclug-devel From mbresnah at visi.com Tue Dec 30 13:27:02 2003 From: mbresnah at visi.com (Mike Bresnahan) Date: Mon Jan 17 14:29:08 2005 Subject: [TCLUG-DEVEL] Logical AND in regular expression Message-ID: <4B412CBD2F57DE4D8163A1B4C0D9879951FA7E@ds67mail.na.bestbuy.com> 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 _______________________________________________ tclug-devel mailing list tclug-devel@mn-linux.org https://mailman.real-time.com/mailman/listinfo/tclug-devel From hopper at omnifarious.org Tue Dec 30 13:45:37 2003 From: hopper at omnifarious.org (Eric Mathew Hopper) Date: Mon Jan 17 14:29:08 2005 Subject: [TCLUG-DEVEL] Logical AND in regular expression In-Reply-To: <4B412CBD2F57DE4D8163A1B4C0D9879951FA7E@ds67mail.na.bestbuy.com> References: <4B412CBD2F57DE4D8163A1B4C0D9879951FA7E@ds67mail.na.bestbuy.com> Message-ID: <20031230194537.GB22786@omnifarious.org> Skipped content of type multipart/signed-------------- next part -------------- _______________________________________________ tclug-devel mailing list tclug-devel@mn-linux.org https://mailman.real-time.com/mailman/listinfo/tclug-devel From foeclan at visi.com Wed Dec 31 13:54:48 2003 From: foeclan at visi.com (Michael Vieths) Date: Mon Jan 17 14:29:08 2005 Subject: [TCLUG-DEVEL] Logical AND in regular expression In-Reply-To: <4B412CBD2F57DE4D8163A1B4C0D9879951FA7E@ds67mail.na.bestbuy.com> References: <4B412CBD2F57DE4D8163A1B4C0D9879951FA7E@ds67mail.na.bestbuy.com> Message-ID: <3FF32988.6040301@visi.com> 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@Visi.com _______________________________________________ tclug-devel mailing list tclug-devel@mn-linux.org https://mailman.real-time.com/mailman/listinfo/tclug-devel From mbresnah at visi.com Tue Dec 30 14:03:27 2003 From: mbresnah at visi.com (Mike Bresnahan) Date: Mon Jan 17 14:29:08 2005 Subject: [TCLUG-DEVEL] Logical AND in regular expression In-Reply-To: <4B412CBD2F57DE4D8163A1B4C0D987996197DF@ds67mail.na.bestbuy.com> Message-ID: <4B412CBD2F57DE4D8163A1B4C0D9879951FA80@ds67mail.na.bestbuy.com> > You must use | in this way: > > ((foo=[^&]*\&bar=[^&]*\&beef=)|(foo=[^&]*\&beef=[^&]*\&bar=)|( > bar=[^&]*\&foo=[^&]*\&beef=)|(bar=[^&]*\&beef=[^&]*\&foo=)|(be > ef=[^&]*\&foo=[^&]*\&bar=)|(beef=[^&]*\&bar=[^&]*\&foo=)) > > Yes, it's ugly, but it's the only way I know of with a > regexp, and I suspect it's actually the only way. Yuk is right! :) If there's no better way, I will go with multiple regular expressions instead. Thanks though. Mike _______________________________________________ tclug-devel mailing list tclug-devel@mn-linux.org https://mailman.real-time.com/mailman/listinfo/tclug-devel From mbresnah at visi.com Tue Dec 30 14:07:39 2003 From: mbresnah at visi.com (Mike Bresnahan) Date: Mon Jan 17 14:29:08 2005 Subject: [TCLUG-DEVEL] Logical AND in regular expression In-Reply-To: <4B412CBD2F57DE4D8163A1B4C0D987996197DE@ds67mail.na.bestbuy.com> Message-ID: <4B412CBD2F57DE4D8163A1B4C0D98799521A96@ds67mail.na.bestbuy.com> > 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: I have only one URL, but the URL query string can have multiple parameters. > Hard to get more specific without knowing what the data format is. The data format is a URL query string. > As for logical AND, it's '&&': > if( ($foo == 1) && ($bar == 2) ) > { // Do stuff } I'm specifically looking for a solution that uses a single regular expression. Mike _______________________________________________ tclug-devel mailing list tclug-devel@mn-linux.org https://mailman.real-time.com/mailman/listinfo/tclug-devel From troy.johnson at health.state.mn.us Tue Dec 30 15:22:27 2003 From: troy.johnson at health.state.mn.us (Troy.A Johnson) Date: Mon Jan 17 14:29:08 2005 Subject: [TCLUG-DEVEL] Logical AND in regular expression Message-ID: Mike, I think logical AND is implied. It's 'out of order' matching you want (if I understand the problem correctly). One way is unrolling the ordered matches (verbose for just three): /foo=.+bar=.+beef=|foo=.+beef=.+bar=|bar=.+foo=.+beef=|bar=.+beef=.+foo=|beef=.+foo=.+bar=|beef=.+bar=.+foo=/ Another way may be with zero-width lookahead matches: /(?=.*foo=)(?=.*bar=)(?=.*beef=)/ but that may be more expensive. All of this is untested, but try it and see if it works for you. Good luck, Troy >>> "Mike Bresnahan" 12/30/03 01:27PM >>> 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. _______________________________________________ tclug-devel mailing list tclug-devel@mn-linux.org https://mailman.real-time.com/mailman/listinfo/tclug-devel