Re: Regular Expressions
| From: | Hans H. Anderson | Date: | Wed, 30 Aug 2000 06:24:58 +0000 |
| Subject: | Re: Regular Expressions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-14333@lists.php.net to get a copy of this message | ||
Hello Scott,
Read on...
On Wed, 30 Aug 2000, Scott Mebberson wrote:
> if (ereg($searchString, $textString)) {
> $hello = ereg($searchString, $textString);
$hello is going to be True or False, depending upon whether there was a
match. Check the docs on this, it's a bit different from ereg_replace,
and it used to trip me up a lot.
This might be a better if statement, as it evaluates only once:
if(ereg($searchString, $textString, $found)) {
---
For your question, try this:
if(ereg("\*([^*]+)\*","*some news item here*",$f)) {
print $f[1];
} else {
print "error";
}
Hans Anderson ~ me@hansanderson.com
http://www.hansanderson.com | PHP, SQL Databases, Flash 5
Animation / Programming,
http://www.goofiness.com | Killer Audio Production, Search
Engines, Brewmeister.