Gossamer Forum
Home : General : Perl Programming :

regex help - need to remove \n from xml files

Quote Reply
regex help - need to remove \n from xml files
I have some xml files that I'm doing some charactor conversion work with (UTF8 -> US7ASCII) in Java. I open up a string buffer and do the conversion but it pukes if it hits a newline charactor in the xml values. I want to write a PERL script to clean up the xml files.
<tag> Cant have any new lines here</tag>
<tag> but many files look like this

</tag>

s/helpfillinthis//g

thanks!
Quote Reply
Re: [diesel] regex help - need to remove \n from xml files In reply to
$var =~ s,\n,,g;
Quote Reply
Re: [Andy] regex help - need to remove \n from xml files In reply to
$var =~ s/\cJ?\cM//g;
Quote Reply
Re: [Paul] regex help - need to remove \n from xml files In reply to
If I'm reading these right, it will remove all new lines, not just ones that are between xml tags????

\c matches one bit? I'm not understanding that syntax. Again thanks for the help!