Java示例替换第一次出现的字符串 Java示例拆分正则表达式2 Java示例检查日期格式1 Java示例替换第一次出现的字符串 import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static void main(String args[]) { Pattern p = Pattern.compile("hello"); String instring = "hello hello hello."; System.out.println("initial String: "+ instring); Matcher m = p.matcher(instring); String tmp = m.replaceFirst("Java"); System.out.println("String after replacing 1st Match: " +tmp); } } Java示例拆分正则表达式2 Java示例检查日期格式1