This is a discussion on Re: [PHP] strings within the PHP General forums, part of the PHP Programming Forums category; * Thus wrote Anthony Ritter (tony@gonefishingguideservice.com): > Curt Zirzow wrote in message: > > > This exact thing was ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
* Thus wrote Anthony Ritter (tony@gonefishingguideservice.com):
> Curt Zirzow wrote in message: > > > This exact thing was talked about earlier today, with the subject > > 'Using eregi_replace()'. > ........................ > > Right. > > However, I've tried using the following code in which the text from the URL > is printed out completely and then I change the variable from $contents to > $text and using the line with preg_replace(), it still outputs the complete > text without the pattern match. hm.. I sort of misunderstood, preg_replace isn't what you need. use preg_match instead. I did some testing you can see the code and results here: http://zirzow.dyndns.org/html/php/te.../parse_doc.php > $newtext= preg_replace("!.*?(REGIONAL.*YORK).*!","$1",$text) ; btw, there these should be single quotes ~~~~~~~~~~^ ^ or "\$1" so php doesn't expand the variable (even though its an illagal php var name.) HTH, Curt -- "I used to think I was indecisive, but now I'm not so sure." |
|
|||
|
Curt Zirzow writes:
> I did some testing you can see the code and results here: > http://zirzow.dyndns.org/html/php/te.../parse_doc.php ................... Thanks Curt. I checked it out and I still pick up the following lines which I was looking to delete on the pattern match. They are: .............. Expires:No;;725283 //line 1 AWUS41 KALY 012014 //line 2 RWSALB // line 3 .................. It could be that when the URL file is being opened and read that these characters are on _three_ different_ lines as opposed to one line/string and the match is not being met. I was looking to delete those lines and to start the match at REGIONAL. Best... TR |