Jump to content

php regex, string ignore html tags


kalster

Recommended Posts

I have a large string with html tags in it

preg_replace('/([\s\S]{5})(?![^\s\S])/', '$1 ', $output);

the regex above chops the long string like below. notice the </p>

 

ddddd ddddd d dddd dd ddd< /p>

 

what i need is like below and with the html tags ignored, still in the string

 

ddddd ddddd ddddd ddddd

 

the above needs to be displayed correctly with the html tags such as bold still in the long string.

 

thank you

Link to comment
https://forums.phpfreaks.com/topic/286503-php-regex-string-ignore-html-tags/
Share on other sites

you need to be more specific about what tags you want to keep and what tags you want to toss. "toss the paragraph tag but leave the html tags such as bold..." well they are ALL html tags. Also, there are several ways that last part can be bolded. You need to show actual content, a "before" and "after" picture (the viewsource, not the rendered), and exactly what tags you want to keep and toss. "Such as.." is vague.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.