Laravel preg_place编译失败:字符类中的范围无效
请查看Blow Error和我的代码。我遗漏了什么吗?
调用堆栈
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_place():编译失败:字符类中的范围无效 偏移量13
致以最良好的问候
解决方案
您现在需要转义连字符,因此只需在s
后添加一个
‘/[^a-z0-9_-s-ءاأإآؤئبتثجحخدذرزسشصضطظعغفقكلمنهويةى]/u’
查看此答案preg_match(): Compilation failed: invalid range in character class at offset
并看到您的正则表达式在此处工作https://3v4l.org/9qni7
相关文章