Jump to content

php regex, string ignore html tags


Go to solution Solved by 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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.