oakb has asked for the wisdom of the Perl Monks concerning the following question:
In my code below, I am trying to extract scalar string data from HTML using a regular expression. I should end up with $message eq '"This is the message."' (please note that the double-quotes should be included in the string) and $sender eq "sender". For some reason that I can't figure out, I always get an empty string in each scalar variable. Please point out the error of my ways....
$data = qq/{"message":"This is the message.","sendAs":"sender"}/; ( $message, $sender ) = $data =~ /\{"message":("[^"]"),"sendAs":"([^"] +)"\}/;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regular expression not working
by ikegami (Patriarch) on Jan 04, 2010 at 17:26 UTC | |
by oakb (Scribe) on Jan 04, 2010 at 17:41 UTC | |
by ikegami (Patriarch) on Jan 04, 2010 at 18:28 UTC | |
by JavaFan (Canon) on Jan 04, 2010 at 18:07 UTC | |
by oakb (Scribe) on Jan 04, 2010 at 17:50 UTC | |
by ikegami (Patriarch) on Jan 04, 2010 at 18:37 UTC | |
by oakb (Scribe) on Jan 04, 2010 at 20:41 UTC |