aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Formatting problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Formatting problem" Watch "Formatting problem" New topic
Author

Formatting problem

Jim Frank
Greenhorn

Joined: Mar 13, 2004
Posts: 27
I am working on an application which allows the user to save a log entry. The users want to cut and paste from MS Word into a JTextField. The problem is is when this is saved, to a String, blocks and weirds characters are saved too, which I think are the tab and other special characters from Word that are not converting right. How can I strip out these characters? I think it is mostly the enter and tab characters that are causing the problems.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
this would need a fair bit of testing

String textToSave = textField.getText().replaceAll("[\\t\\n\\x0B\\f\\r]","");

basically the 'whitespace' characters, except for 'space' itself
Jim Frank
Greenhorn

Joined: Mar 13, 2004
Posts: 27
Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Formatting problem