in reply to How do I regex for characters like ¾, ¼ ?
use strict; use warnings; open OUT, '>', 'delme1.txt'; print OUT <<STR; The use of the Porter and Ale is more prevalent in England. In the United States ½ Old and ½ New Ale is usually used when this drink is called for, unless otherwise specified. STR close OUT; open IN, '<', 'delme1.txt'; my $str = do {local $/; <IN>}; close IN; $str =~ s/½/½/g; print $str;
Prints:
The use of the Porter and Ale is more prevalent in England. In the United States ½ Old and ½ New Ale is usually used when t +his drink is called for, unless otherwise specified.
as expected using ActiveState Perl v5.8.7 built for MSWin32-x86-multi-thread under Windows XP.
Maybe the file you are using is not the character format that you think it is?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How do I regex for characters like ¾, ¼ ?
by Plankton (Vicar) on Sep 10, 2007 at 03:35 UTC | |
by Anonymous Monk on Sep 10, 2007 at 04:19 UTC | |
by Plankton (Vicar) on Sep 10, 2007 at 04:26 UTC | |
by GrandFather (Saint) on Sep 10, 2007 at 04:10 UTC |