Click here to get back home

Regex - Unexpected match for /\r/

 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
Regex - Unexpected match for /\r/ Fred Hare 02-06-2007
Posted by Fred Hare on February 6, 2007, 8:28 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

Posted by Joe Smith on February 11, 2007, 9:16 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
Unexpected regex Behavior May 14, 2006, 9:02 am
Unexpected RegEx results February 26, 2007, 2:29 pm
Re: Unexpected RegEx results February 26, 2007, 4:05 pm
Multi-Match (to Array) Regex with a precodition match? August 5, 2007, 2:43 pm
RegEx Help, Please? (match after n) June 26, 2005, 10:49 pm
regex to match any url February 14, 2006, 4:02 pm
Printing regex match September 25, 2004, 1:27 pm
regex: match at least one of two expression October 12, 2004, 10:07 am
match regex split January 5, 2005, 9:09 pm
RegEx How to not match a string October 3, 2005, 3:54 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap