regex - Java Regular expression special charecters -
i want replace xx*
x
.
i tried string.replaceall("xx*", "x");
but in regex *
special need give \*
give \
in java need give \\
==> should work string.replaceall("xx\\*", "x");
but when string contains xx*
above statement fails in replacing xx*
x
please thank you
you have reassign result of
replaceall()
call string variable - method returns new string opposed modifying string call on.don't use
replaceall()
!! usereplace()
when dealing literal strings:string = string.replace("xx*", "x");
Comments
Post a Comment