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
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 ! :)

Link to comment
Share on other sites

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.