Docstoc

java lect 19

Document Sample
java lect 19 Powered By Docstoc
					Matcher functions
  boolean find()
  Attempts to find the next subsequence of the
  input sequence that matches the pattern.
  boolean lookingAt()
  Attempts to match the input sequence,
  starting at the beginning, against the pattern.
  boolean matches()
  Attempts to match the entire input sequence
  against the pattern.
Some more Matcher function
  Pattern pattern()
  Returns the pattern that is interpreted by this
  matcher.
  String replaceAll(String replacement)
  Replaces every subsequence of the input that
  matches the pattern with the given string.
  String replaceFirst(String replacement)
  Replaces the first subsequence of the input
  that matches the pattern with the given
  string.
Rules for writing Regex in Java

   \w ->alphabetical character [a-zA-Z]
  \W -> any non-alphabetical character
  \d -> digit [0-9]
  \D -> non digit
  \s -> space character
  \S -> non-space character
  \b -> word boundary
Specifying the limit of occurence

   \\d? -> 0 or 1 times
   \\d* -> 0 or more times
   \\d+ ->1 or more times
  \\d{n,m} -> minimum n times and
  maximum m times
Write Regular Expressions
   For identifying all email addresses of the
  form abc@xyz.com
  For identifying telephone number as per
  Indian standard like (city code) number
     Example (022) 25764728
  For representing string containing at least 4
  a’s
  For representing strings ending with (-ing, -
  ment, -tion, -es)
References
  URL:
     http://www.regular-expressions.info/tutorial.html
     http://java.sun.com/j2se/1.5.0/docs/api/

				
DOCUMENT INFO
Description: java and its various features
About if any file u wil find copyright contact me it will be remove in 3 to 4 buisnees days. add me on sanjaydudeja007@gmail.com or visit http://www.ohotech.com/