HamNRye has asked for the wisdom of the Perl Monks concerning the following question:
I'm certain this is old hat to many of the regs here, but I've been bustin' a synapse here trying to get this done.
So, here's the idea... Translating info coming out of a legacy system to XHTML. There are control codes "\x90" "\x8F" that tell me useful things elsewhere in the text, but need to be excluded within certain tags. There could be any number of them within the tags.
Here is some sample text:
</Mil,p12.10,3,15,d>But he won<cm EQ>t say whether he would veto bill, which is short of what he wanted
Human readable instead of funky boxes...
</Mil,p12.10,3,15,d>But he won<cm EQ>t say whether \x90 he would veto bill, which \x90 is short of what he wanted \x90 \x9D
My current regex looks like $text =~ s/(<\/Mil[^>]*>.*?)[\x90\x8F](.*?\x9D)/$1$2/ig; And this only removes the very first control character as expected.
How can I create the regex so that between the open tag </Mil.*> and the close char \x9D I can remove any number of \x8F and \x90 characters?
This all takes place in the middle of ~100 different transforms that need to be done to each file, so having this as a one-liner would be nice.
Edit: Current regex updated to use [^>]* per Moritz's suggestion.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Curious Regex
by ikegami (Patriarch) on Feb 11, 2009 at 18:15 UTC | |
|
Re: Curious Regex
by moritz (Cardinal) on Feb 11, 2009 at 18:12 UTC | |
by HamNRye (Monk) on Feb 11, 2009 at 18:20 UTC | |
|
Re: Curious Regex
by almut (Canon) on Feb 11, 2009 at 18:35 UTC | |
by HamNRye (Monk) on Feb 11, 2009 at 19:16 UTC | |
|
Re: Curious Regex
by ELISHEVA (Prior) on Feb 11, 2009 at 18:34 UTC | |
by HamNRye (Monk) on Feb 11, 2009 at 18:39 UTC | |
by ELISHEVA (Prior) on Feb 11, 2009 at 18:48 UTC |