How can I remove everything from a string apart from letters? I have an input field for first names.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
In PHP, you can use (as suggested by @rczajka and @mario):
preg_replace('/\PL/u', '', $str)
Working Example: http://codepad.viper-7.com/V78skl
You may want to checkout this Tutorial for regex
回答2:
$new_string = preg_replace('/[^a-z]/i','',$old_string);
回答3:
$new_string = ereg_replace("[^A-Za-z]", "", $string );