Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 正则表达式是否删除所有英文和阿拉伯数字?_Regex_Unicode_Preg Replace_Preg Match - Fatal编程技术网

Regex 正则表达式是否删除所有英文和阿拉伯数字?

Regex 正则表达式是否删除所有英文和阿拉伯数字?,regex,unicode,preg-replace,preg-match,Regex,Unicode,Preg Replace,Preg Match,我希望正则表达式删除阿拉伯语和英语数字 我的varibale是 $variable=“12121212ABDHSتتآآ۳۳۽۴729384234owisw” 我要删除所有数字!比如: ABDHSتتآآowiswoisw 我找到了下面的表达式,但不起作用 $newvariable = preg_replace('/^[\u0621-\u064A]+$', '', $variable); 感谢您的帮助您可以使用 $newvariable = preg_replace('/\d+/u', ''

我希望正则表达式删除阿拉伯语和英语数字

我的varibale是 $variable=“12121212ABDHSتتآآ۳۳۽۴729384234owisw”

我要删除所有数字!比如:

ABDHSتتآآowiswoisw

我找到了下面的表达式,但不起作用

 $newvariable = preg_replace('/^[\u0621-\u064A]+$', '', $variable);
感谢您的帮助

您可以使用

$newvariable = preg_replace('/\d+/u', '', $variable);

默认情况下,
\d
与ASCII数字匹配,但当添加
u
修饰符时,它会启用
PCRE\u UCP
选项(连同
PCRE\u UTF8
),使
\d
与所有Unicode数字匹配

见:

此选项更改PCRE处理\B、\B、\D、\D、\S、\S、\W、, \w、 以及一些POSIX字符类。默认情况下,只有ASCII码 可以识别字符,但如果设置了PCRE_UCP,则Unicode属性 而是用于对字符进行分类

如果只需要将匹配限制为ASCII和您选择的匹配,您可以修复正则表达式:

preg_replace('/[0-9\u0621-\u064A]+/u', '', $variable)

您可以使用
'/\d+/u'
不起作用:
'/\d+/u'
起作用-