Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

easy regex question: stops on some white space?



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.







BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org