Page 1 of 1
\W+ with ;
Posted: Fri Mar 31, 2006 2:26 am
by shiznatix
would this:
Code: Select all
$input = preg_replace('/\W+ \;/', '', $input);
replace everything that is NOT alphanumeric, a space, a underscore, or a semi-colon? I don't want this to do anything crazy that I am not aware of.
Posted: Fri Mar 31, 2006 4:53 am
by Chris Corbyn
Nope... that would replace anything NOT alphanumeric, FOLLOWED BY a space, FOLLOWED BY a semi-colon
Use a character class to give groups of characters to replace

[abc]
Posted: Fri Mar 31, 2006 9:39 am
by feyd
For your information, \W doesn't really do what you want either.
Code: Select all
[feyd@home]>php -r "$a = ''; for($i = 0; $i < 256; $i++, $a .= chr($i)); echo preg_replace('#\W#','',$a);"
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyzâèîÄÜ£₧ƒ¬▓│╡╣║└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷°∙·√ⁿ²■
Posted: Sat Apr 01, 2006 9:17 am
by shiznatix
this does not work. it does not allow the ; character to pass through
Posted: Tue Apr 18, 2006 5:24 am
by shiznatix
kinda a bump since i was not able to figure it out but instead of the ; character I need to let the - character through. this does not work
Posted: Tue Apr 18, 2006 7:55 am
by feyd
Posted: Tue Apr 18, 2006 8:13 am
by shiznatix
thanks mate. beautiful as always