in reply to pattern matching
This won't do anything at all. For starters, you need to use =~ for matching and substitutions. The star (*) is a quantifier, and won't do anything unless you put it after something. In fact, it will give you an error the way you have it now, since it doesn't follow anything. Maybe something like this will be improved:$string = m/($start)(*)($end)/;
As an aside, you probably want to start getting used to use strict (although not absolutely necessary in such a small script you have here). Also, CGI::Carp qw/fatalsToBrowser/ will send fatal messages to the browser, making it easier to debug.$string =~ /$start(.*?)$end/s;
Update: match newlines and no case sensitivity. Thanks Juerd and cLive ;) I figured I would miss something! :)
Update: as Yves pointed out, (.*?) would be the best way to go! Thanks, Yves.
- Derek Soviak
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(cLive ;-) Re: pattern matching
by cLive ;-) (Prior) on Jan 16, 2002 at 22:39 UTC | |
|
Re: Re: pattern matching
by Juerd (Abbot) on Jan 17, 2002 at 00:51 UTC |