Re: UTF-16LE fails in substitution
[email protected] (David Graff)
| Newsgroups | perl.unicode |
|---|---|
| Message-ID | <[email protected]> |
Minor tweak to the regex substitution in that "subroutine version" that I
posted previously -- it should be:
$editdata =~ s/(\x{feff}?(?:<\?.*?\?>\s*)*)/$1$comment/s;
(note the optional BOM at the beginning of the match pattern -- if the data
contains a BOM, then $comment will be inserted after it). As before, if
nothing in the data matches the pattern, then $comment will be inserted at
the beginning of the string.
If you make sure that the original data contains at least one "<?...?>"
string, change the final "*" to "+", and then add a test to check whether
the substitution succeeded.
Dave Graff