get specific character
问题 I would like to remove Zero from a string, below is an example : String a : 020200218-0PSS-0010 a.replaceall("-(?:.(?!-))+$", "**REPLACEMENT**") Actual : 020200218-0PSS-0010 Expected : 020200218-0PSS-10 I'm using this regex to catch -0010 : -(?:.(?!-))+$ I just dont know what to do in the REPLACEMENT section to actually remove the unused zero (not the last zero for exemple "10" and not "1") Thanks for reading! 回答1: You could use something like: (?<=-)0+(?=[1-9]\d*$) It translates to "find all