"be consistent" | |
PerlMonks |
Re: Control Characters (\xNN) in HTMLby scain (Curate) |
on Oct 18, 2001 at 20:42 UTC ( [id://119733]=note: print w/replies, xml ) | Need Help?? |
The reason your substitution isn't working is because you aren't
escaping the first backslash \x probably has a special meaning
and even if it doesn't \x means x (backslashed \> for example
means >).
To fix the regex, rewrite it like this: The \d+ will work as you think it should (that is, as you wrote it). Scott Update: I should have guessed, but the \x followed by a two digit hex number means to look for a hex number, which is probably what confused you in the first place: you are looking for the text representation of a hex number (ie, \x92) which is plain text, not the hex number itself. The Real Update: OK, you said For instance, the single character \x92; scain, read the problem (or as my High School Chemistry teacher wrote RTGDP). \x followed by digits matches a hex nubmer. What I don't know is how to get it to match a range of numbers. You might try several things, like [\x90-\xFF], which if Perl DWIM, would mean to match any hex number in that range. Also, since \x actually matches the number, what you really want to capture is the whole thing; so assuming the range works as I have written it, rewrite the regex like this: I am really fuzzy on whether that will work, but don't have an easy way to test it; let me know. Note that this way, you no longer need the e at the end of the regex.
In Section
Seekers of Perl Wisdom
|
|