正则表达式无法正常工作 - preg_replace或preg_match

时间:2021-09-10 16:52:11

I have the following regex code:

我有以下正则表达式代码:

$search_query=preg_replace('#[a-z. .a-z]#i', ' ', $_POST['searchquery']);

My database is lower case. The interpretation that I am going for is: $search_query should allow all letters on a case insensitive basis and any white space but ignore symbols and numbers. It should not replace anything since it is case sensitive. And it should process 'search_query'.

我的数据库是小写的。我要解释的是:$ search_query应该允许所有字母不区分大小写和任何空格但忽略符号和数字。它不应该替换任何东西,因为它区分大小写。它应该处理'search_query'。

Where am I going wrong...? My hashtags are correct and is i=case insensitive...

我哪里错了......?我的主题标签是正确的,并且i =不区分大小写......

Examples of INPUTS are: user enters "populate". Another user enters "bLaH". A third user enters "BIG".

INPUTS的示例是:用户输入“填充”。另一个用户输入“bLaH”。第三个用户输入“BIG”。

1 个解决方案

#1


0  

'#[^a-z ]#i' seems to work very well.

'#[^ a-z] #i'似乎效果很好。

#1


0  

'#[^a-z ]#i' seems to work very well.

'#[^ a-z] #i'似乎效果很好。