08 String Processing
08 String Processing
String Processing
8-2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Command-Line Arguments
8-3 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Command-Line Arguments
8-4 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Properties
8-5 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Loading and Using a Properties File
8-6 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Loading Properties from the Command Line
8-7 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
PrintWriter and the Console
import java.io.PrintWriter;
}
}
8-8 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
printf format
8-9 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Quiz
System.out.println(sb.toString());
}
}
Character Description
[^abc] Would match any character that is not “a,” “b,” or “c” in that position
[a-c] A range of characters (in this case, “a,” “b,” and “c”)
Quantifier Description
Anchor Description
Target String it was the best of times or it was the worst of times
Pattern (\\S+?)\\.(\\S+?)@(\\S+)
Pattern p1 = Pattern.compile("h1");
Matcher m1 = p1.matcher(header);
if (m1.find()){
header = m1.replaceAll("p");
System.out.println(header);
}
}
}