Results 1 to 8 of 8
  1. #1
    mohammedelbes is offline Member
    Join Date
    Jan 2011
    Posts
    3
    Rep Power
    0

    Default Regular Expressions problem

    Hi

    can anybody help me write a regular expresion for a string like this

    "X,Y,Z,A,B,C,Time"

    X,Y,Z,A,B,C is a 3 digits number

    Time is a double value with anynumber of digits with two decimal places.

    Thank you very much

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Well, where's your attempt at it? See the API docs for Pattern for the symbols available and google for a regex tutorial (does not need to be a Java regex tutorial, simply regex). After you post your attempt we will help you correct it. I would, however, suggest simply using the split method of String.

  3. #3
    JavaHater is offline Senior Member
    Join Date
    Dec 2010
    Posts
    165
    Rep Power
    4

    Default

    Quote Originally Posted by mohammedelbes View Post
    Hi

    can anybody help me write a regular expresion for a string like this

    "X,Y,Z,A,B,C,Time"

    X,Y,Z,A,B,C is a 3 digits number

    Time is a double value with anynumber of digits with two decimal places.

    Thank you very much
    here's something for you to start with (this can be further simplified, but let's not make it too complicated first)
    Java Code:
    "\d{3},\d{3},\d{3},\d{3},\d{3},\d{3},\d+\.\."
    Note:, you still have to escape what is necessary for it to work.

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Well, the last part definately won't work.

  5. #5
    JavaHater is offline Senior Member
    Join Date
    Dec 2010
    Posts
    165
    Rep Power
    4

    Default

    yes, it won't work ( cos it for OP to find out :) )

  6. #6
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    The entire thing should have been "for OP to find out", or to at least attempt.

  7. #7
    JavaHater is offline Senior Member
    Join Date
    Dec 2010
    Posts
    165
    Rep Power
    4

    Default

    Quote Originally Posted by masijade View Post
    The entire thing should have been "for OP to find out", or to at least attempt.
    Nah, I prefer to give examples where appropriate and let them find out for themselves.

  8. #8
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

Similar Threads

  1. regular expressions
    By sozeee in forum New To Java
    Replies: 3
    Last Post: 12-06-2010, 10:58 PM
  2. Using regular expressions for search
    By carderne in forum New To Java
    Replies: 9
    Last Post: 05-24-2009, 05:58 AM
  3. Regular Expressions in java
    By blue404 in forum Advanced Java
    Replies: 2
    Last Post: 09-26-2008, 04:43 AM
  4. Using Quantifiers in regular expressions
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-10-2008, 11:43 AM
  5. Regular expressions quantifiers
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-25-2007, 12:18 PM

Posting Permissions

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