June 2012
Intermediate to advanced
136 pages
2h 50m
German
//Suche nach Spider-Man, Spiderman, SPIDER-MAN usw.
public class StringRegexTest {
public static void main(String[ ] args) throws Exception {
String dailybugle = "Spider-Man Menaces City!";
//Regex muss gesamten String prüfen.
String regex = "(?i).*spider[- ]?man.*";
if (dailybugle.matches(regex)) {
System.out.println("Treffer: " + dailyBugle);
}
}
}//Datumsangaben in Formaten wie MM/DD/YYYY, //MM-DD-YY ... erkennen import java.util.regex.*; public class MatchTest { public static void main(String[ ] args) throws Exception { String date = "12/30/1969"; Pattern p = Pattern.compile("^(\\d\\d)[-/](\\d\\d)[-/](\\d\\d(?:\\d\\d)?)$"); Matcher m = p.matcher(date); if (m.find( )) { String monat = m.group(1); String ...Read now
Unlock full access