This question already has an answer here:
- String.replaceAll without RegEx 2 answers
Problem:-
"hello.java".replaceAll(".","$");
when I compile this, it gives regex illegal argument. I can escape special characters, but I want to take both arguments as input from user. So I want another solution.
In other words, I am asking for a method so that javac will treat both arguments of replaceAll method as normal string, not as regex patterns. Such that
Output should be : hello$java
Aucun commentaire:
Enregistrer un commentaire