Results 1 to 3 of 3
  1. #1
    kishan's Avatar
    kishan is offline Member
    Join Date
    Apr 2009
    Posts
    57
    Rep Power
    0

    Default How "Pattern.matches(regex, input)" function works?

    Pattern.matches(regex, input);
    matches function do this:
    "Compiles the given regular expression and attempts to match the given input against it.".

    I cant understand the above statement.
    can u explain me how the above function works and for what purpose it will be used?

  2. #2
    Supamagier is offline Senior Member
    Join Date
    Aug 2008
    Posts
    384
    Rep Power
    7

    Default

    It's really useful, I use it a lot. You can use it to search Strings for the regex you specify. Can be used for... something that checks if an email is valid for example, or to strip html (remove everything between <> and &; or something. ;))

    Have a look at this. :)
    Last edited by Supamagier; 04-25-2009 at 02:25 PM. Reason: used --> use
    I die a little on the inside...
    Every time I get shot.

  3. #3
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,585
    Rep Power
    12

    Default

    OP: Do you know what a regular expression is? If not have a read of Regular Expressions in Sun's Tutorial.

Similar Threads

  1. trouble with Scanner(new File("input"));
    By ronyosi in forum New To Java
    Replies: 9
    Last Post: 10-28-2010, 12:34 AM
  2. Count lines cointaining "word" in input file
    By gwithey in forum New To Java
    Replies: 5
    Last Post: 04-02-2009, 06:23 AM
  3. Replies: 2
    Last Post: 01-24-2009, 07:56 PM
  4. Can't get my "if" statement to read user input
    By daletron3030 in forum New To Java
    Replies: 7
    Last Post: 01-16-2009, 06:24 AM
  5. Replies: 1
    Last Post: 10-20-2008, 08:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •