Regular Expression

Regular Expression:

  • Pattern used to define pattern [ Pattern.compile(pattern) ]
  • Matcher matches
  • Flags
    • Pattern.CANON_EQ Enables canonical equivalence
    • Pattern.CASE_INSENSITIVE Enables case-insensitive matching.
    • Pattern.COMMENTS Permits whitespace and comments in the pattern.
    • Pattern.DOTALL Enables dotall mode.
    • Pattern.LITERAL Enables literal parsing of the pattern.
    • Pattern.MULTILINE Enables multiline mode. (?m).
    • Pattern.UNICODE_CASE Enables Unicode-aware case folding. (?u).
    • Pattern.UNIX_LINES Enables UNIX lines mode.(?d)
  • Quantifier
    • x* : zero or more occurrence
    • x? : zero or one occurrence
    • x+: one or more occurrence
    • x{n} : exactly n occurrence
    • x{n,} : at least n occurrence
    • x{n,m}: range between n and m
    • Greedy quantifier (+) : try to match longest string
    • Reluctant (? after quantifier) : opposite to greedy match one char at a time
    • Possessive (+ after quantifier) : like greedy but if the entire string doesn’t match, then it doesn’t try removing characters from end.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: