阅读背景:

使用正则表达式检测HTML格式的字符串

来源:互联网 

I'm trying to detect whether a string is XML/HTML formatted, or some other format like CSV or JSON, which may contain HTML as data, or just generic text which may contain random < or > characters. I am NOT trying to validate complete XML or HTML documents--the strings I am testing may just be snippets of XML/HTML, or they may be snippets of something else. So, my criteria are that the string must contain at least one properly-formatted XML tag, and that tag must start at the beginning of the string, barring any whitespace. (At this point, you may have guessed that I am trying to auto-detect the mime-type of textual content before sending it back to the browser. BTW, I'm in PHP.)I'm trying to detect whether a string is XML/HT




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: