# Thread: Regular Expressions problem

1. Member
Join Date
Jan 2011
Posts
3
Rep Power
0

## 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. Senior Member
Join Date
Jun 2008
Posts
2,562
Rep Power
8
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. Senior Member
Join Date
Dec 2010
Posts
165
Rep Power
4
Originally Posted by mohammedelbes
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. Senior Member
Join Date
Jun 2008
Posts
2,562
Rep Power
8
Well, the last part definately won't work.

5. Senior Member
Join Date
Dec 2010
Posts
165
Rep Power
4
yes, it won't work ( cos it for OP to find out :) )

6. Senior Member
Join Date
Jun 2008
Posts
2,562
Rep Power
8
The entire thing should have been "for OP to find out", or to at least attempt.

7. Senior Member
Join Date
Dec 2010
Posts
165
Rep Power
4
Originally Posted by masijade
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. Senior Member
Join Date
Jun 2008
Posts
2,562
Rep Power
8
IOW "do it for me" facilitator.

#### Posting Permissions

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