What is the Pattern class?

Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.

What is the Pattern class?

Rating:

Pattern is a final class present in the java.util.regex package. It is used to define and hold regular expressions. This class works with the Matcher class to perform the match operations.

The Pattern class defines no public constructors. To create a pattern, a static method compile is used as follows:

static Pattern compile(String pattern): This static method compiles the given regular expression into a pattern.

The other important methods of the Pattern class are as follows:

  • static Pattern compile(String regex, int flags)

    This static method compiles the given regular expression into a pattern with the given flags.


  • public Matcher matcher(CharSequence input)
    This method creates a matcher that will match the given input against this pattern. It takes the character sequence to be matched and returns a matcher for the pattern.


  • static boolean matches(String regex, CharSequence input)
    This static method compiles the given regular expression and attempts to match the given input against it.


  • public String pattern()
    This method returns a String that represents the regular expression from which this pattern was compiled.


Rating:



Other articles

Click here to Article home

 
uCertify.com | Our Company | Articles | Privacy | Security | Contact Us | News and Press Release | uCertify India
MCSE: MCSA, MCTS, MCITP    JAVA Certification: SCJP, SCWCD Cisco Certification: CCNA, CCENT, A+, Network+, Security+
Oracle Certification: OCP 9i, OCP 10g, OCA 9i, OCA 10g CIW foundation    EC-212-32    CISSP    Photoshop ACE    Adobe Flash ACE
© 2008 uCertify.com. All rights reserved. All trademarks are the property of their respective owners.