• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SCJP 5.0 objective 3

 
Ravith Botejue
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can somone explain to me about the regular expressions and how greedy, reluctant, possesive quantifiers work, also the new locale class and the printf() method. I have read the MZ's SCJP Tiger Notes but I am still not clear.
--------------------

RB
 
Henry Wong
author
Marshal
Pie
Posts: 20882
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ravith Botejue:
can somone explain to me about the regular expressions and how greedy, reluctant, possesive quantifiers work, also the new locale class and the printf() method. I have read the MZ's SCJP Tiger Notes but I am still not clear.
RB


To be blunt, regular expressions are *very* complex. And in many ways, can be regarded as a complete language on its own.

Unfortunately, the Java Documentations assumes that you already know regular expressions, and just summarized the topic.

The best documentation that I have seen on Regular Expressions are actually part of the perl documentation. Search the perl.com website for the regular expression documentation. And while you are at it, learning perl may not be a bad idea either...

Henry
 
Philip Heller
author
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fortunately, the objectives only mention greedy quantifiers, which are the default behavior.

The quantifiers you need to know about are:

* ... matches zero or more occurrences of the preceding pattern.
+ ... matches 1 or more occurrences of the preceding pattern.
? ... matches zero or 1 occurrence.

A greedy quantifier will match the longest possible sequence of characters. A reluctant or possessive quantifier might not match the longest possible sequence, depending on some really intricate principles that fortunately aren't required knowledge for the SCJP exam.


Makes me wonder what future enhancements we might see? How about an obsessive-compulsive quantifier, which consumes all characters even if it's not appropriate. Or a manic-depressive quantifier, which cycles between greedy and reluctant behavior.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic