trimming the code out. help!!!!

Status
Not open for further replies.

aydndrc

Inactive
Apprentice
Hey,, I have a text area in my wesite,, and when a user paste from a word document it takes some wierd code into my database with it. I need a way to trim that out before it gets into database, any help will be appreciated.. thanks.....

code is like :

Normal   0       &nbsp ; false   false   false       &nb sp;       &nbsp ;        & nbsp;    MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;}
 
you can use str_replace("replace this","with this",$string);

but really you need to find out why that is being appended to your string.
 
I can not trim that with that because code is not always same. it changes based on what style they have in the document beng pasted from word document.
 
From what you've posted, seems like you want to trim out all the html tags. To be more clear, can you post an example of the input, and how you want the output?
 
are you directly taking the input from the HTML page? if yes then the above code is justified as &nbsp represents Non breaking space which it print essentially wherever there is a space and the text is not to wrapped around.

what you could do is try to take input from each component independently and not from the whole file at once.
 
Add a rich text box like the one where you can post replies here in Techenclave, and assign the text to a string.

Which Server Side language are you using?
 
Status
Not open for further replies.