Results 1 to 3 of 3
  1. #1
    blue404 is offline Member
    Join Date
    Sep 2008
    Posts
    2
    Rep Power
    0

    Default Regular Expressions in java

    hi
    how can i use Regular Expressions in java to define this pattern and check that name and id aren;t null.
    name:id

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,563
    Rep Power
    25

    Default

    If name and id are String variables, then you can use the == operator to test for null values.
    I don't know how a regex can look at nothing. It could look at an empty string.
    The == test for null is the simplest.

    Or is the problem: Your have a String: 'null:xxx' or 'xxx:null' and you want to see if that string contains the string "null"?

    Look at the Pattern and Matcher classes. Search will probably get you several examples.
    Last edited by Norm; 09-25-2008 at 04:25 PM.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    To find the null you can't use a regular expression, not a 'null' string. So as Norm you can use == operator in simple way.

    I'm not clear what you are asking here anyway. Can you more descreptive

Similar Threads

  1. Regular expressions from command prompt
    By GenkiSudo in forum New To Java
    Replies: 2
    Last Post: 09-21-2008, 02:40 PM
  2. Using Quantifiers in regular expressions
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-10-2008, 10:43 AM
  3. Capturing Groups using regular expressions
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-25-2007, 11:19 AM
  4. Regular expressions quantifiers
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-25-2007, 11:18 AM
  5. regular expressions and string matching
    By DennyLoi in forum New To Java
    Replies: 1
    Last Post: 11-16-2007, 10:15 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
  •