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.


In reply to Curious Regex by HamNRye

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.