special character « replace « Java Regex Q&A

Home
Java Regex Q&A
1.Development
2.find
3.group
4.Match
5.matcher
6.number
7.Operation
8.parse
9.Pattern
10.replace
11.validation
12.word
Java Regex Q&A » replace » special character 

1. replace special characters in string in java    stackoverflow.com

I want to know how to replace the string in Java. E.g.

String a = "adf?sdf";
How can I replace and avoid special characters?

2. Regex for replacing special characters    coderanch.com

String name= "12E463~1.jpg"; String newName = name.replaceAll("[a-zA-Z1-90_\\- \\.]*","_"); String name has some value which contains some special characters. I want all characters apart from A-Z a-z 0-9 . (dot) _ (underscore) - (hyphen) to be replaced with an _ (underscore) So I should get 12E463_1.jpg in newName But using the above regex the opposite happens. All characters apart from the special ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.