File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Java in General
Regex help, replacing/espacing characters
Joined: Feb 12, 2009
Jul 31, 2009 10:58:35
I needed a little help writing a function in
that does the follow for escaping, I want to use regular expressions, I need the following characters to be replaced by a “~”
I posted it in beginners, but i think it is more fitting in this area.
The special characters are replaced as follows:
1. Newline, backspace, Control-M, carriage return, vertical tab characters are each replaced with "~"
2. Double quotes (") are replaced with single quotes (')
3. Then single quotes are escaped by inserting a backslash before each one.
Can someone give me a hand writing this? I don’t know regular expressions so it’s difficult for me to get going on this.
Author and ninkuma
Joined: Jan 10, 2002
Jul 31, 2009 11:02:27
Please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place. Please
for more information.
Asking smart questions
Books by Bear
I agree. Here's the link:
subject: Regex help, replacing/espacing characters
replace method for String
how to read a file in a string
Changing spelling 'or' to 'our'
Can you simulate String.replace(...) & String.contains(...)
Escaping special characters regex/function help
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013