regex pattern match and extract

From: Date: Thu, 10 May 2001 16:32:53 +0000
Subject: regex pattern match and extract
Groups: php.general 
Request: Send a blank email to php-general+get-52318@lists.php.net to get a copy of this message
$sql="select nfo_gname from galaxy_nfo limit 1"; $result=db_query($sql); if ($result) { while (list($nfo_gname)=mysql_fetch_row($result)) { echo ("$nfo_gname"); ereg ("\[[a-zA-Z0-9]\]", $nfo_gname, $regs); echo $regs[1]; I'm trying to match any thing between [] and pull it from the string and print it to the page. I want the []'s matched as well. IE: $nfo_gname contains the following information [VET]We r NOT [PA]-Crew [TC] should $regs[1] contain: [VET] [PA] and [TC] ?

« previous php.general (#52318) next »