For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > June 2005 > Removing *some* XML Character encodings with regular expression









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Removing *some* XML Character encodings with regular expression
Toby Stuart

2005-06-08, 8:57 am

Hi All,

I'm trying to remove chars 00-29 from an XML document and need a regular
expression to do so...

Before: $s = "abc@123";
After : $s should only contain: "abc@123"

I've tried a few things with ranges etc. but can't get it. Obviously I
could check if the number is <= 29 and then replace but would prefer a
single regex if possible.

Thanks

Toby Stuart
Ing. Branislav Gerzo

2005-06-08, 8:57 am

Toby Stuart [TS], on Wednesday, June 8, 2005 at 16:47 (+1000 ) made
these points:

TS> Before: $s = "abc@123";
TS> After : $s should only contain: "abc@123"

TS> I've tried a few things with ranges etc. but can't get it. Obviously I
TS> could check if the number is <= 29 and then replace but would prefer a
TS> single regex if possible.

maybe you are looking for:

my $xml = "abc@123";
$xml =~ s/&\#(\d+)(??{ $1 <= 29 ? "" : "(?!)" });//g;
print $xml;

hope helps.

--

How do you protect mail on web? I use http://www.2pu.net

["Bother," said Pooh, as the hippopotamus' breath knocked him out cold]


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com