Re: preg_replace() 'space' the final frontier

From: Date: Wed, 30 Jan 2002 19:50:00 +0000
Subject: Re: preg_replace() 'space' the final frontier
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-82799@lists.php.net to get a copy of this message
In article <000801c1a9c5$26007460$0100007f@localhost>, hdanaher@earthlink.net (Hugh Danaher) wrote: > What I am trying to do is have a line of text break at a "space" after > reading 19 words. Having read the various methods of finding and replacing > one character with another, I settled on preg replace as my best choice, but > this function doesn't accept a space in the regular expression slot. What > can I do to get around this, or is there a better function than the one I > selected? > > $statement=preg replace(" ","<br>",$original,19); > > Warning: Empty regular expression in /home/www/host/document.php on line 71 It's not the space character that's prompting the error, it's the absence of regex delimiters around the space. $statement=preg replace("/ /","<br>",$original,19); <http://www.php.net/manual/en/ref.pcre.php> <http://www.php.net/manual/en/pcre.pattern.syntax.php> -- CC

« previous php.general (#82799) next »