Christopher Hahn wrote: > Hey, > > I seem to be missing a piece of the puzzle....I want to define a character > class ([]) > with atoms to (not) match involve negative look-ahead assertions.....but no > joy. > > I am reading a stream of text that may contain the two segments \\n and \" > > I want to define a regexp that will match up to the first of either of > these. > > ...ie. something like ([^]*) where the character class is just the two > sequences above. > > ...but they are not characters at all, but strings, and so I wonder how to > approach this. > > Question: how best to do something to set > > $1 == every character in the string up to and not including the first of > either a \\n or a \" > > That is all. (something like $strval =~ m/ (.* (?! \\ (?= \" | \\ (?= n) ) ) > )/x;) > > I am going to use this regexp in a Parse::RecDescent Production, and have > other Rules to > deal with the \\n and \" strings. > > I am banging on this and will report when something good comes out of it, > but please do > chime in with any "best practices" that suggest themselves to you.
I assume that \\n is actually 3 characters and not a newline. It should be as simple as : use strict; foreach ( '1: asd asdf adf asd \\n asd adf \" ad dasf dsaf ', '2: asd asdf adf asd \n asd adf \" ad dasf dsaf ', '3: asd asdf adf asd asd adf \" ad dasf \\n dsaf ', '4: asd asdf adf asd asd adf " ad dasf \n dsaf ', ) { if (/^(.*)(?:\\\\n|\\")/) { print "$1\n"; } } __END__ -- ,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED] (_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED] / ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/ -/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff) _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs