vinay vinay - 1 month ago 102
Java Question

Dangling meta character '*' near index 6

When I'm replacing the character

*
with an empty string I get the following exception :
Dangling meta character '*' near index 6
.

Here is my code :

String siteDelimit=subjectStudy.getSubject().getSubjCdDelimiter();
//think siteDelimit having **
subject.setSubjectCode(subject.getSubjectCode().replaceAll(siteDelimit, ""));

Answer

replaceAll() takes a regex, therefore you get this error. If you don't want to use regex, you can use the method which don't take regexes, i.e. replace()