473,385 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to match carriage returns and line feeds

I am using ActiveState's Perl on Windows and am trying to remove an excess
\x0d character I am getting (not sure why I am getting it, but doesn't
matter if I can easily be rid of it). What I see in my text is sequences of
\x0d\x0d\x0a - and I am trying to replace them with simply CRLF (\x0d\x0a).
I admit to being a newbie to Perl, so maybe I am just missing something.
Why wont the following work:

$text =~ s/\x0d\x0d\x0a/\x0d\x0a/gs;

Thanks

--Jeff--
Jul 19 '05 #1
1 9036
In article <Lt*********************@twister.southeast.rr.com> ,
Schroeder <jf*******@nc.rr.com> wrote:
I am using ActiveState's Perl on Windows and am trying to remove an excess
\x0d character I am getting (not sure why I am getting it, but doesn't
matter if I can easily be rid of it). What I see in my text is sequences of
\x0d\x0d\x0a - and I am trying to replace them with simply CRLF (\x0d\x0a).
I admit to being a newbie to Perl, so maybe I am just missing something.
Why wont the following work:

$text =~ s/\x0d\x0d\x0a/\x0d\x0a/gs;


It works for me:

#!/usr/local/bin/perl
#
use strict;
use warnings;

my $text = "abc\x0d\x0d\x0adef";
p("Before",$text);
$text =~ s/\x0d\x0d\x0a/\x0d\x0a/gs;
p('After',$text);
sub p
{
my($title,$text) = @_;
print "\n$title:\ntext=<$text>\n";
print join(' ',map { ord $_ } split(//,$text)),"\n";
}
__OUTPUT__
Before:
text=<abc
def>
97 98 99 13 13 10 100 101 102

After:
text=<abc
def>
97 98 99 13 10 100 101 102

You need to post a short program demonstrating the problem you are
having.

FYI; this newsgroup is defunct. Try comp.lang.perl.misc in the future.
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Robert Oschler | last post by:
Hello, I am using the following function to try and strip both carraige returns and line feeds, ASCII 13 and 10 respectively, from a string. It doesn't seem to be working: x = filter(lambda...
6
by: | last post by:
Hi, I want to send an Email using ASP (I know how to to this) The body of the Email contains several variabels How do I concat string values and separate them by carriage returns/ Line feeds? ...
1
by: Tim Mavers | last post by:
I am using the MailMessage class and am dynamically building the message body field. I know I am using String and not String builder but I don't want to worry about that now. The problem is after...
3
by: st | last post by:
Hi, I've a routine that exports a DB query to Excel by building an XmlDocument and saving to a XmlTextWriter. I'm having trouble with carriage returns in a mailing address not showing up in the...
2
by: Matt Mercer | last post by:
Hi all, I am having a frustration problem, and I have read about 25 newsgroup postings that do not have a satisfying answer :) The problem appears to be common where carriage returns are lost...
2
by: Lila Godel | last post by:
I am having a problem with the download of web pages via the WebClient.DownloadFile function in the specialized VB.Net 2003 I.E. plug-in I am designing to speed up the work on my latest project. ...
0
by: J.Marsch | last post by:
I am having a problem in which ASP.Net web services are corrupting my data. I know that my problem is related to the standard way of encoding carriage return linefeeds, so I need to figure out how...
4
by: Kevin Vogler | last post by:
I'm still feeling my way around XML parsing and have an app that uses XML reader and works fine as long as the XML is pretty but doesn't find all the elements when the XML is all on a single line...
1
by: Jashuva | last post by:
Dear All, Please advice how to remove carriage returns (line breaks) in the attached xml file. Regards, Jashuva
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.