What is the correct way to detect whether string inputs contain HTML or not?

前端 未结 13 721
旧时难觅i
旧时难觅i 2020-12-23 15:08

When receiving user input on forms I want to detect whether fields like \"username\" or \"address\" does not contain markup that has a special meaning in XML (RSS feeds) or

13条回答
  •  春和景丽
    2020-12-23 15:21

    Regex is still the most efficient way of solving your problem. It doesn't matter what frameworks you plan to use, or are advised to use, the most efficient way would still be a custom regex code. You can test the string with a regex, and remove (or convert) the affected section using htmlcharacter function.
    No need to install any other framework, or use some long-winded application.

提交回复
热议问题