Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

preg match that skips text

use the not operator

3:50 pm on Sep 25, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 30, 2008
votes: 0

I'm continuing my work on a Wordpress plugin and would like to include a check that skips text that the user inputs. I'm thinking of ways to do this, and currently have a preg_replace statement as the best way.

What type of statement could I use? Say for example I want to replace double spaces ( ) that occur after everything except periods (. ) .

Obviously preg_match('/!. /') doesn't work, so what else can I do?

3:51 pm on Sept 25, 2008 (gmt 0)

Senior Member

joined:Nov 12, 2005
votes: 0

$pattern = "/[^.]*\s\s/";
$new_string = [url=http://www.php.net/preg_replace]preg_replace[/url]($pattern, "", $string);

Try something along those lines. :)


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members