Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to delete escape characters in word or excel or any text editor?

Status
Not open for further replies.

bnageshrao

Programmer
Mar 17, 2001
83
US
I got a flat file from the main frame and when I opened it in any text editor or even in excel I see escape characters which looks like . I can high light that and delete it. But my problem is that it is a huge file and that kind of characters are found at many places throught the file. How can I use replace function to replace  by spaces so that I get a file without those characters.
 

I usually highlight the [COLOR=black yellow][/color] characters, copy them into Clipboard (Ctrl-C), use replace functionality (usually Ctrl-H), paste what I have in Clipboard (Ctrl-V) and specify what you want to replace with, like a space.

That will find all occurrences of  and replace it with a space.


Have fun.

---- Andy
 
Not familiar with Word or text docs, but in Excel =Trim(Clean(CellRef)) usually cleans out most, if not all.

Another Victim of the recession
 
It did not help, I had tried it before posting the question on the forum. remember this character came from main frame. I can copy and paste, but replacing will not replace it at all.
 
I can copy and paste, but replacing will not replace it at all. "

But if you copied three of them (as Andy suggested) it should replace blocks of three, as THAT is the replace. The problem is, of course is that if you have five, then the first three are replaced, but the next two are not.

Depending on whether it is the same character, you could try using VBA to run through and remove them.

May take a while if the document is really long.

Gerry
 
Hi bnageshrao,

If you open the file with MS Word, you could use Find/Replace with the 'wildcards' Find option to serach for:
[\^1-\^31]
That will strip out any of the ASCII characters lower than the space character (32). If that's too drastic, you could narrow the character range - use an ASCII table to decide what the range should be.

If you've got strings that include spaces etc with these special characters and you want to delete those other characters too, you'll need to provide more details.

Cheers

[MS MVP - Word]
 
macropod, does that not strip out any carriage returns AND legitmate spaces between words? Seems drastic to me.

Gerry
 
Hi Gerry,

Yes, it strips out carriage reaturns (and tabs), but not spaces. As I said in my post:
If that's too drastic, you could narrow the character range - use an ASCII table to decide what the range should be.

I'm sure that, if bnageshrao were to post back with a more fullsome description of the problem - including a representative sample of the data - you or I (or any number of tek-Tips contributors) could propose a workable solution.

Cheers


[MS MVP - Word]
 
I asked management to deal with the posted sample as it was messing up the whole thread.

If the data has come from a mainframe, it is likely that the rogue characters are all in the same position and you could do a find and replace with a pattern like: [blue](?{27})?{5}(*)^13[/blue] and replace it with [blue]\1 \2^p[/blue] - this example will force spaces into positions 28 to 32 of each line (assuming the lines end in paragraph marks - if they have hard line breaks you can adjust it accordingly)

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top