I have a problem with matching words at the end of line, that contains dash ( -
).
For example:
circum-
stances
My regex
matches this as 2 words (circum, stances)
, But I need to remove dash and the sign of new line a make one word.
Try this,
public static void main(String[] args) {
String str = "circum-\nstances";
System.out.println("[Original Content:"+str+"]");
str = str.replaceAll("-(\\s+)", "");
System.out.println("[Modified Content:"+str+"]");
}
You'll get this as the output, I believe this is what you were looking for.
run:
[Original Content:circum-
stances]
[Modified Content:circumstances]
BUILD SUCCESSFUL (total time: 0 seconds)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.