更新时间:2023-02-18 09:15:34
preg_replace('/^' . preg_quote($g_lang_prefix,'/') . '/', '', $t_var );
如果需要$g_lang_prefix
作为通用正则表达式,则省略preg_quote
If you need $g_lang_prefix
working as a common regex then omit preg_quote
preg_replace('/^' . $g_lang_prefix . '/', '', $t_var );
(非常明显)
如果您需要第二种解决方案,但您的$g_lang
甚至可以包含此字符/
,那么您至少需要对其进行转义:
Also if you need this second solution, but your $g_lang
can contain even this char /
then you need to escape at least it:
preg_replace('/^' . str_replace('/','\/',$g_lang_prefix) . '/', '', $t_var );