mercredi 25 mai 2016

Java: replacing a substring with other string [duplicate]

This question already has an answer here:

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