On Wed, Jun 08, 2005 at 03:11:10PM +0200, Dotan Cohen wrote: > Now, I know that this is easy, but I am embarassed to say that I can't > find a regex tutorial that will show me how to match any occurances of > x and replace them with one x: > > xxxxx >x > xx > x > x > x > > $string="I have xxxxxxxx apples!"; > $string=preg_replace("-regex here-","x", $string); > print "$string"; > > I have x apples! > > I searched marc because I know that I've seen this, but I don't know > on what keywords to search. I know that php uses perl-compatable > regular expressions, but in no tutorial did I find this. I know that * > matches any amount of occurances of a string, but formulating it to do > it in the middle of a string of text I could not get. This really belongs on a PHP list, not here. Go to http://www.php.net/manual/en/ref.pcre.php and the perl docs, and take a look at what parentheses do in pattern matching. -- Charles Curley /"\ ASCII Ribbon Campaign Looking for fine software \ / Respect for open standards and/or writing? X No HTML/RTF in email http://www.charlescurley.com / \ No M$ Word docs in email Key fingerprint = CE5C 6645 A45A 64E4 94C0 809C FFF6 4C48 4ECD DFDB
Attachment:
pgpa7N6q7SD16.pgp
Description: PGP signature