Mark text in HTML

后端 未结 5 601
迷失自我
迷失自我 2021-01-14 03:39

I have some plain text and html. I need to create a PHP method that will return the same html, but with before any instances of th

5条回答
  •  说谎
    说谎 (楼主)
    2021-01-14 04:32

    You'll need to get deep into the dark woods of Regex for this, but I'm not sure what value doing so would have if you want to apply the same class to every element. If you're hell-bent on every element having a new span, then this page might help: http://haacked.com/archive/2004/10/25/usingregularexpressionstomatchhtml.aspx

    Really the more logical thing to do would be to just apply class="marked" to the body element unless you've got a good reason for adding a duplicate class to everything on the page.

提交回复
热议问题