Re: Regular Expressions

From: Date: Thu, 31 Aug 2000 21:17:00 +0000
Subject: Re: Regular Expressions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-14689@lists.php.net to get a copy of this message
You will need delimiters around those search parameters. You will also want them ungreedy having .* in the middle. preg_match("/^\*.*\*/U", $textString, $matches); preg_match("/\#.*\#/U", $textString, $matches); "WILSON, Nick" wrote: > > 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 > > > > > > -- > 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 -- Monte Ohrt <monte@ispi.net> http://www.ispi.net/

« previous php.general (#14689) next »