balgeary has asked for the wisdom of the Perl Monks concerning the following question:
Hi all,
I'm having trouble getting my regular expressions to match more than one character. When I give it a file that contains the word "text", this will print "hi":
while ($line = <STDIN>){ if ($line =~ /t/){ print "hi"; } }
But this won't, even though I can see in my input file that there's a word "text"
while ($line = <STDIN>){ if ($line =~ /te/){ print "hi"; } }
Is this a bug, or am I doing something wrong in my code? I've tried uninstalling and reinstalling Strawberry Perl, and trying strings of characters that are in the input file, but it's still not working.
UPDATE: Hi! I figured out what it was -- the input file was encoded as UCS-2 Big Endian for some reason. Thank you for the responses!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regular expression only matches a single character
by stevieb (Canon) on Jun 11, 2015 at 21:40 UTC | |
|
Re: Regular expression only matches a single character
by Eily (Monsignor) on Jun 11, 2015 at 21:34 UTC |