Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.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
Php preg_match_all():未知修饰符'/';在里面_Php_Regex - Fatal编程技术网

Php preg_match_all():未知修饰符'/';在里面

Php preg_match_all():未知修饰符'/';在里面,php,regex,Php,Regex,我目前遇到了一个问题与正则表达式,虽然它有它需要的一切,有一个正则表达式长度限制?任何帮助都将不胜感激 $possible_tags_in_regex = "/(<b>|<\/b>|<i>|<\/i>|<u>|<\/u>|<tt>|<\/tt>|<font size=[1-7]>|<font color=#[a-fA-F0-9]>|<\/font>)*/";

我目前遇到了一个问题与正则表达式,虽然它有它需要的一切,有一个正则表达式长度限制?任何帮助都将不胜感激

$possible_tags_in_regex = "/(<b>|<\/b>|<i>|<\/i>|<u>|<\/u>|<tt>|<\/tt>|<font size=[1-7]>|<font color=#[a-fA-F0-9]>|<\/font>)*/";
            // Add possible tags between every character in a string
            $regex = implode($possible_tags_in_regex, str_split($regex));
            $regex = $possible_tags_in_regex.$regex.$possible_tags_in_regex;

            // Format every regex every match with given tags
            if (preg_match_all($regex, $input, $to_be_replaced)) {
$problem_tags_in_regex=“/(||||||||||)*/”;
//在字符串中的每个字符之间添加可能的标记
$regex=内爆($regex中可能的标签,str_split($regex));
$regex=$probably_tags_in_regex.$regex.$probably_tags_in_regex;
//使用给定标记格式化每个正则表达式和每个匹配项
if(preg_match_all($regex,$input,$to_be_替换)){

您的整个模式需要分隔符,但您在开始时添加了分隔符,然后进行内插和连接,因此最终会有许多分隔符。请从\u regex中的
$mablue\u tags\u中删除分隔符,并在末尾添加:

$possible_tags_in_regex = "(<b>|<\/b>|<i>|<\/i>|<u>|<\/u>|<tt>|<\/tt>|<font size=[1-7]>|<font color=#[a-fA-F0-9]>|<\/font>)*";
// Add possible tags between every character in a string
$regex = implode($possible_tags_in_regex, str_split($regex));
$regex = "/$possible_tags_in_regex.$regex.$possible_tags_in_regex/";

这是怎么回事?如果你想去除所有这些,为什么要经历所有这些麻烦呢?为什么不直接使用
strip_tags()
带有选项?另外,
标记已弃用/过时。您可能在某个地方使用旧代码并不得不替换所有这些代码,对吗?条带化标记对我的解决方案没有帮助。正确谢谢工作得很好:)
$possible_tags_in_regex = "(<b>|</b>|<i>|</i>|<u>|</u>|<tt>|</tt>|<font size=[1-7]>|<font color=#[a-fA-F0-9]>|</font>)*";
// Add possible tags between every character in a string
$regex = implode($possible_tags_in_regex, str_split($regex));
$regex = "~$possible_tags_in_regex.$regex.$possible_tags_in_regex~";