regex - Java Regular Expressions -
i trying write this:
pattern p = pattern.compile("mar\\w"); matcher m = p.matcher("mary"); string result = m.replaceall("\\w");
the result ideally "y"
. ideas?
your question not clear, think want use lookahead:
pattern p = pattern.compile("mar(?=\\w)"); matcher m = p.matcher("mary"); string result = m.replaceall("");
see online: ideone
or use capturing group:
pattern p = pattern.compile("mar(\\w)"); matcher m = p.matcher("mary"); string result = m.replaceall("$1");
see online: ideone
Comments
Post a Comment