Regular expression Pattern class options - Java Regular Expressions

Java examples for Regular Expressions:Pattern

Introduction

When using the following method to create Pattern instance

Pattern pattern = Pattern.compile ("[A-Z][a-zA-Z]*", Pattern.CASE_INSENSITIVE | Pattern.UNIX_LINES); 

We can have the following options.

Flag nameEmbedded expression Description
UNIX_LINES (?d) Enables Unix lines mode.
CASE_INSENSITIVE (?i)Enables case-insensitive pattern matching and may incur a small performance penalty.
UNICODE_CASE(?iu) Unicode-aware, case-folding mode.
COMMENTS (?x)Permits whitespace and comments in the pattern.
MULTILINE (?m) Turns on multiline mode.
DOTALL(?s) Dot (.) character matches any character, even line separators.
CANON_EQNoneEnables canonical equivalence.

Related Tutorials