laravel preg_replace 编译失败:字符范围无效 class
laravel preg_replace Compilation failed: invalid range in character class
请查看错误和我的 code.Something 我遗漏了什么吗?
调用堆栈
in /app/Http/Controllers/Controller.php line 217
at HandleExceptions->handleError('2', 'preg_replace(): Compilation failed: invalid range in character class at offset 13', '/app/Http/Controllers/Controller.php', '217', array('string' => 'gegegeg', 'separator' => '-'))
at preg_replace('/[^a-z0-9_\-\s-ءاأإآؤئبتثجحخدذرزسشصضطظعغفقكلمنهويةى]/u', '', 'gegegeg') in Controller.php line 217
at Controller->make_slug('gegegeg') in AdsController.php line 153
at AdsController->FormAds('14', '71', '97', object(Request))
at call_user_func_array(array(object(AdsController), 'FormAds'), array('main_id' => '14', 'sub_id' => '71', 'typ_id' => '97', object(Request))) in Controller.php line 80
代码
echo preg_replace('/[^a-z0-9_-s-ءاأإآؤئبتثجحخدذرزسشصضطظعغفقكلمنهويةى]/u', '', 'gegegeg');
错误:
preg_replace(): Compilation failed: invalid range in character class
at offset 13
此致
您现在需要转义连字符,所以只需在 \s
后添加一个
'/[^a-z0-9_\-\s\-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-
查看此答案preg_match(): Compilation failed: invalid range in character class at offset
看看你的正则表达式在这里工作 https://3v4l.org/9qni7
请查看错误和我的 code.Something 我遗漏了什么吗?
调用堆栈
in /app/Http/Controllers/Controller.php line 217
at HandleExceptions->handleError('2', 'preg_replace(): Compilation failed: invalid range in character class at offset 13', '/app/Http/Controllers/Controller.php', '217', array('string' => 'gegegeg', 'separator' => '-'))
at preg_replace('/[^a-z0-9_\-\s-ءاأإآؤئبتثجحخدذرزسشصضطظعغفقكلمنهويةى]/u', '', 'gegegeg') in Controller.php line 217
at Controller->make_slug('gegegeg') in AdsController.php line 153
at AdsController->FormAds('14', '71', '97', object(Request))
at call_user_func_array(array(object(AdsController), 'FormAds'), array('main_id' => '14', 'sub_id' => '71', 'typ_id' => '97', object(Request))) in Controller.php line 80
代码
echo preg_replace('/[^a-z0-9_-s-ءاأإآؤئبتثجحخدذرزسشصضطظعغفقكلمنهويةى]/u', '', 'gegegeg');
错误:
preg_replace(): Compilation failed: invalid range in character class at offset 13
此致
您现在需要转义连字符,所以只需在 \s
'/[^a-z0-9_\-\s\-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-
查看此答案preg_match(): Compilation failed: invalid range in character class at offset
看看你的正则表达式在这里工作 https://3v4l.org/9qni7