On Sat, May 27, 2006 8:58 am, Merlin wrote: > I am somehow lost when it comes to regex. I am trying to remove ! and > ? > characters from a string. Could somebody please help me to get a > working > regex running for that? > > I tried: $str = preg_replace('/\!\?\./', ' ', $str); An alternative: $str = preg_replace('/[\\!\\?\\.]*/', ' ', $str); And usual rant #37: \ and ' are special characters inside of '' and you really SHOULD escape them, even though PHP will let you get away with not doing it, yea, even unto it being a "documented feature" that \x will turn into \x so long as x is not \ or ' I also think str_replace() might be more appropriate, but would be cautious about claims on speed for str_replace versus preg_replace, if, for example, the array() of characters to be replaced was HUGE... You'll have to benchmark on your own gear *IF* it matters to you, which I doubt. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php