Re: Regular Expression Query

From: Date: Sat, 06 Jan 2001 19:37:47 +0000
Subject: Re: Regular Expression Query
Groups: php.general 
Request: Send a blank email to php-general+get-33046@lists.php.net to get a copy of this message
Sorry if this comes through twice: Thanks for those two points. I still haven't cracked this. I'm trying to break the problem down so I've tried the following example: $semifile2 = ereg_replace("\#39","YES",$semifile); But where there is a string: #39 it doesn't replace it with the word YES, however if I remove \# then it does replace 39 with YES Thanks for the help so far. Allan www.cybercandy.co.uk ----- Original Message ----- From: "Rasmus Lerdorf" <rasmus@php.net> To: "Cybercandy Ltd" <allan@cybercandy.co.uk> Cc: <php-general@lists.php.net> Sent: Saturday, January 06, 2001 6:53 PM Subject: Re: [PHP] Regular Expression Query > > I think the most difficult thing I've encountered so far in trying to > > learn PHP, as a novice programmer, is regular expressions. > > > > I'm trying to use ereg_replace on a string containing a large quantity > > of data taken from a webpage which I then parse using > > the explode function. > > > > One regularly occuring string is: (Reference #xxx) > > > > Where xxx is a number of up to 3 digits. > > > > I want to replace this string using back references to just xxx > > and I've tried using the following: > > > > $out = ereg_replace("\(Reference #.([0-9]+).\)","\\1",$in); > > > > I just can't suss why this doesn't work. > > > > Any pointers anyone? > > > What are those .'s for in your regex? > > Just make it: "\(Reference #([0-9]+)\)" > and I bet it will work. > > with the .'s there you would only get the middle digit of your xxx > > -Rasmus > > > -- > 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 (#33046) next »