in reply to Match function not providing results
The reason your regular expressions don't work is that you are using them wrong.
The perlre manpage (use perldoc perlre to view it) gives a short introduction to regular expressions and how to construct them.
Here's a short attempt at a hands-on introduction geared towards your problem :
A regular expression that matches a single character is /f/. This one would match barfoo.
A regular expression that matches a sequence of characters is, for example, /foo/, which would match barfoobaz, but which would not match barfobaz, because the second o is missing.
To now construct a regular expression that matches one character out of a set of characters, we neet to look at the set constructors for regular expressions, [ and ]. The characters between [] in a regular expression will match any of the characters in a string. So our above examples could be rewritten to /[f]/, which would still only match the letter f, and /[f][o][o]/, which will first try to match the set containing only a f, and after that an o and after that another o. But that is not what you want. You want to match (for example), the string ab. To that, we extend the set from containing one character to two characters : /[ab]/ will match (for example) afoo and bar and zob.
So you will want to construct from the answer data a regular expression and collect all correct answers in a []-set, and match the string against that RE.
perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Match function not providing results
by chriso (Sexton) on Dec 14, 2001 at 20:59 UTC | |
by Corion (Patriarch) on Dec 14, 2001 at 21:38 UTC |