easy regex question: stops on some white space?
Tom Metro
blu-5a1Jt6qxUNc at public.gmane.org
Mon Jun 11 15:08:05 EDT 2007
Eric C wrote:
> so i'm trying to write a script that will give me
> everything from "info" all the way to "END." when i
> use something like:
>
> preg_match("/info.*/", $var1, $var2);
>
> unfortunately this stops at "and now for a couple
> returns:" and not at "END." i've tried several
> modifiers such as /m and /s but no luck.
If you print $var1, or whichever of those is supposed to contain the
string you are matching against, do you see the full multi-line string?
Assuming PHP accurately copied features from Perl, those modifiers will
alter what the "." meta-character matches, but it won't help you if your
variable contains only one line of data. (BTW, /s is the one you want.)
In other words, if your code elsewhere is iterating over the lines of
the file you are trying to parse, you'll need to take other steps to
either reassemble the lines into a single variable, or alter the way the
file is loaded.
If you have a system with Perl installed on it, you might find Perl's RE
documentation helpful. Run: perldoc perlre
-Tom
--
Tom Metro
Venture Logic, Newton, MA, USA
"Enterprise solutions through open source."
Professional Profile: http://tmetro.venturelogic.com/
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
More information about the Discuss
mailing list