Java示例删除空格 Java示例字符串中特定单词的最后索引 Java示例匹配电话号码 Java示例删除空格 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示例字符串中特定单词的最后索引 Java示例匹配电话号码