RE: [PHP] Regular Expressions

From: Date: Wed, 30 Aug 2000 06:55:33 +0000
Subject: RE: [PHP] Regular Expressions
Groups: php.general 
Request: Send a blank email to php-general+get-14326@lists.php.net to get a copy of this message
Something like preg_match("^\*.*\*", $textString, $matches); $headline = $matches[2]; preg_match("\#.*\#", $textString, $matches); $headlineLink = $matches[2]; > -----Original Message----- > From: Scott Mebberson [mailto:scott@redbluedesign.com.au] > Sent: Wednesday, 30 August 2000 16:36 > To: php-general@lists.php.net > Subject: [PHP] Regular Expressions > > > hi Guys, > > I have the string "*newsItem in Here*#news/news_item_1.php#\" which is > loaded in from a .txt file (see code below). > > I want to extract what is inbetween the ** and set the value > to the variable > $headline, I then want to get what is in between the ## and > set the value to > the variable $headlineLink. Here is my code below, can anyone > help me out?? > > if (!$text=fopen("string.txt", "r")) { > echo ("A critical file --> \"string.txt\" <-- is missing, > this program has > been terminated."); > } else > > $textString = fread($text, 4000); > fclose($text); > } > > $searchString = "^[a-zA-Z][0-9\.\-][ \f\r\t\n]$"; // this is > just here > becuase I was trying to search for anything but it gave me errors > > if (ereg($searchString, $textString)) { > $hello = ereg($searchString, $textString); > echo (ereg($searchString, $textString).NL); // .NL is a > constant that I > have for <br>/n > } else { > echo ("didn't work and \$hello is equal to \"$hello\"".NL); > } > > It would be great if someone could help me?? > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > >

« previous php.general (#14326) next »