A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
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.
Books by Bear
I agree. Here's the link:
subject: Regex help, replacing/espacing characters
how to read a file in a string
replace method for String
Escaping special characters regex/function help
Can you simulate String.replace(...) & String.contains(...)
Changing spelling 'or' to 'our'
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013