Java示例删除空格1 Java 示例 Word 的最后一个索引2 Java示例匹配电话号码1 Java示例删除空格1 import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static void main(String[] argv) { String str = "This is a Java program. This is another Java Program."; String pattern="[\\s]"; String replace = ""; Pattern p = Pattern.compile(pattern); Matcher m = p.matcher(str); str = m.replaceAll(replace); System.out.println(str); } } Java 示例 Word 的最后一个索引2 Java示例匹配电话号码1