From: Thomas Hurst Date: 2002-04-11T03:12:15+09:00 Subject: Re: regex: how to negate sequences? * Tobias Reif (tobiasreif@pinkjuice.com) wrote: > Can you explain the ?= syntax, or point to it's doc? perldoc perlre (?=regexp) A zero-width positive lookahead assertion. For example, /\w+(?=\t)/ matches a word followed by a tab, without including the tab in $&. There's also: (?!regexp) A zero-width negative lookahead assertion. For example /foo(?!bar)/ matches any occurrence of ``foo'' that isn't followed by ``bar''. But note this isn't the same as negation; it's asserting that the area ahead of the match does or does not contain something. Another useful one is: (?:regexp) This groups things like ``()'' but doesn't make backrefences like ``()'' does. So if you want to match a string but not save the value: /foo (?:bar|fee)(.*)/ Will result in $1 pointing to the second set of ()'s. You can also embed pattern modifiers in there: irb(main):001:0> 'CASE INSENSITIVE' =~ /[A-Z]+ (?i)[a-z]+/ ; p $& "CASE INSENSITIVE" -- Thomas 'Freaky' Hurst - freaky@aagh.net - http://www.aagh.net/ - Good salesmen and good repairmen will never go hungry. -- R.E. Schenk