Click here to get back home

Help simplify complex regexp needing positive lookahead and reluctant quantifers

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Help simplify complex regexp needing positive lookahead and reluctant quantifers david.karr 03-20-2005
Get Chitika Premium
Posted by david.karr on March 20, 2005, 11:29 am
Please log in for more thread options
>>
>> [snip]
>>
>> > if I print "$1\n",
>> > the file prints just fine. But, if I do something like print "$1 after
>> > \n", the whole output is messed up. If I print "before $1\n", nothing
>> > prints at all. If I print "before $1 after\n", only after prints.
>>
>> not really sure, but could be a rogue "\r" in $1,


> There
> is a rogue carriage return (0xd) in the string

> Is there something I can do to deal with this
> situation?


Repair the corrupted file:

perl -p -i -e 'tr/\r//d' bad_file


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas

Posted by Sherm Pendley on March 20, 2005, 4:59 pm
Please log in for more thread options
>>
>> [snip]
>>
>> > if I print "$1\n",
>> > the file prints just fine. But, if I do something like print "$1 after
>> > \n", the whole output is messed up. If I print "before $1\n", nothing
>> > prints at all. If I print "before $1 after\n", only after prints.
>>
>> not really sure, but could be a rogue "\r" in $1,


> There
> is a rogue carriage return (0xd) in the string

> Is there something I can do to deal with this
> situation?


Repair the corrupted file:

perl -p -i -e 'tr/\r//d' bad_file


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas

Similar ThreadsPosted
How do I use a variable-width positive look behind assertion? November 6, 2007, 5:52 pm
Simplify Variable Number of Regex Groups June 14, 2007, 11:14 pm
lookahead bug (at least in 5.8.4) June 11, 2007, 12:09 pm
Lookahead peculiarity March 9, 2006, 9:18 am
help: negative lookahead and backref in regex? December 28, 2004, 4:02 pm
Regular expression lookahead question January 13, 2005, 3:57 pm
Negative lookahead regex clarification needed January 19, 2005, 12:09 pm
Complex Records help September 1, 2004, 4:47 am
complex numbers January 9, 2005, 1:36 am
Complex extensions in C September 16, 2006, 10:32 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap