using preg_replace or equivelent
| From: | Derek C Hopkins | Date: | Wed, 31 Jan 2007 19:10:59 +0000 |
| Subject: | using preg_replace or equivelent | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-27424@lists.php.net to get a copy of this message | ||
Hi All
Not knowing cgi-script I am having trouble understanding the preg_replace function in PHP.
What I want to do is remove all ocurances of the following items from a string
All spaces, open brackets, close brackets, apostriphy, and period (full stop)
from a string such as theseAudlin,Mary Ann,Spalding,14,412 Audsley,David.,Leeds,23,354 Audsley,David (Male),Leeds,23,354 Audsley,David O'Shannesey,Leeds,23,354 My thoughts were the following code But it does not work # need to remove punctuation in forname, ( .
) ZZZZZZZZZZZZZZZZZZZZZZZZZZZZ $patterns[0] = '/./'; $pattern[1] = '/(/'; $pattern[2] = '/)/'; $pattern[3] = "'"; $pattern[4] = '/ /'; $replacements[0] = "-"; $replaements[1] = "2"; $replacements[2] = "3"; $replaements[3] = "4";$forname = preg_replace($patterns,$replacements ,$forname); $surname = preg_replace($patterns,$replacements ,$surname); What happens is all characters get changed to - (the first 0 replacement. Any help with this or another solution would be appreciated. Cheers Derek
Derek C Hopkins, Phone +1(450)678-7768 6640, Biarritz, Fax +1(450)678-4252 Brossard, E-Mail derek.hopkins@sympatico.caQC, Canada, J4Z-2A2. ==== FreeBMD - England and Wales - Birth - Marriage and Death Transcriptions <http://FreeBMD.rootsweb.com> ==== Check out FreeBMD Scan2 Syndicate page (revised daily) Please bookmark our new home http://www.scan2.ca/scan2.html ==== Check out QFHS Marriage Transcription Project page (revised daily) (Quebec Family History Society) Please bookmark our new home http://www.scan2.ca/qfhs.html Check out my web page (22jan1997) Last Revised 28 May 1998 <http://www.cam.org/~hopkde/index.html> Check out Abney Park Indexing Project (revised 14 MAR 2000, 195,000 names) <http://www.cam.org/~hopkde/abney.html> Check out my web Ramsgate page <http://members.adept.co.uk/hopkde> Check out the Quebec Family History web page <http://www.qfhs.ca/index.html>