Re: regular expression Question

From: Date: Wed, 13 Sep 2000 23:18:31 +0000
Subject: Re: regular expression Question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-16661@lists.php.net to get a copy of this message
Sonia Tsui wrote: > > What is the equivalent way of doing the following in PHP? I tried this > syntax in PHP, it doesn't work. > > I can do this in perl > > say each line are in this format > file 1: myfile2_ext.txt > file 2: myfile2_ext.txt > : > : > > foreach (@lines) > if (/file (.*): (.*)_ .*.txt/) { > ehco("$2<br>") > } Hi, It's pretty similar but expressed in a function (not tested but should be close): foreach (WHATEVER as $k => $line) if (preg_match("/file (.*): (.*)_ .*.txt/", $line, $m)) echo "$m[2]<br>"; Ciao, Andreas Pour http://www.kde.com/ : Everything KDE http://apps.kde.com/: The Latest in KDE Applications

« previous php.general (#16661) next »