Jump to content

replace <br something> with <br> something


lfernando

Recommended Posts

Hi there,

 

I have a string with a bunch of line breaks tags (<br/>) that have stuff inside, for example:

Hello<br <del>/>This is</del> <ins>How are you?<br </ins>/>  

 

I basically need to find <br XXX/> and replace it with <br/> XXX  so my code should look like this

 

Hello<br/> <del>This is</del> <ins>How are you?</ins><br/>  

 

I tried using a find and replace array but I know this would be so much easier with regex! Little help!?

 

Thank you! :)

Link to comment
https://forums.phpfreaks.com/topic/261635-replace-with-something/
Share on other sites

Thank you! Yes I know the code is messy....

 

My users update documents using a WYSIWYG editor (www.tinymce.com). Whenever a change is made, it's recorded in the history. For this I use Paul Butler's string diff algorithm (http://paulbutler.org/archives/a-simple-diff-algorithm-in-php/)

 

For example, the document says "Hello are you there?" and the user changes it to "Hello who is there?". The history will say:

"2012.10.40: Hello are you who is there?"

 

For some reason whenever the string has a path to a file, or bullet points, or in some other scenarios, some strikethrough  tag (<del>) and/or underline tag (<ins>) gets placed inside the break. I think it may be the combination of the algorithm and the WYSIWYG editor. I looked at them trying to figure out what whas happening but couldnt, figured it'd be easier just to "clean up" the history before publishing instead of investing any more time in these two pieces of code that otherwise work well for me.

 

Thanks again for your code I will try it out ! :)

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.