© Kishori Sharan 2017
Kishori SharanBeginning Java 9 Fundamentalshttps://doi.org/10.1007/978-1-4842-2902-6_18

18. Regular Expressions

Kishori Sharan
Montgomery, Alabama, USA
In this chapter, you will learn:
  • How to create regular expressions
  • How to use convenience methods in the String class to perform regular expression-based find-and-replace
  • How to use the Pattern class to compile regular expressions
  • How to use the Matcher class to match a regular expression against an input string
  • How to use groups in regular expressions
  • How to perform advanced find-and-replace using the Matcher class
All example programs in this chapter are a member of a jdojo.regex module, as declared in Listing 18-1.
// module-info.java
module jdojo.regex {
    exports com.jdojo.regex; ...

Get Beginning Java 9 Fundamentals: Arrays, Objects, Modules, JShell, and Regular Expressions now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.