doujiao9866 2019-06-05 05:40
浏览 88

如果字符串使用HTML标记格式正确,如何获取

I want to verify if a string is correctly formatted with HTML Tags. For example:

    "<b>This Is wrong"

This Is the function I used.

function closetags($html) { 

 preg_match_all('#<([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result); $openedtags = $result[1];

   preg_match_all('#</(([a-z])+)>#iU', $html, $result); $closedtags = $result[1]; $len_opened = count($openedtags); 

   if (count($closedtags) == $len_opened) { return true; } else { return false;}
}

I've already tried to use this but when the string Is:

"<B>This is correct</>"

It doesn't work..

Thank you in advance Francesco

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料