String text = "Hello World!"; Pattern p = Pattern.compile("Hello"); Matcher m = p.matcher(text); if (m.find()) { } else { } String text = "www.hoge.net"; Pattern p = Pattern.compile("\\.net"); Matcher m = p.matcher(text); String replaced = m.replaceFirst(".info"); System.out.println(replaced); Matcher m = p.matcher(st); String replaced = m.replaceAll(""); String text = "Name: Regular Expressions";