Forum Moderators: coopster

Message Too Old, No Replies

preg match that skips text

use the not operator

         

wesg

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

10+ Year Member



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?

eelixduppy

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




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

Try something along those lines. :)