Regular Expressions
| From: | Scott Mebberson | Date: | Wed, 30 Aug 2000 05:35:47 +0000 |
| Subject: | Regular Expressions | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-14321@lists.php.net to get a copy of this message | ||
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??