Eclipse Java RegEx

Hello all,

If this is in the wrong area please let me know!

I have revently installed Eclipse 3.1.1 and have been plugging away.  I attempted to use a regex that seemed fairly straight forward for validating some input but it seems that Eclipse or Java does not like certain escape clauses (\.) for example.
I am using jdk 1.4 and have forced compatibility to 1.4 for all source and compiled objects.  Not sure what else there is.  Java docs say this should work.

The regPattern:

            String regPattern = "([0-4[^2]][0-9][0-9][0-9][0-9][1-9])(\.[0-9][0-5])?";

The compile error:

Exception in thread "main" java.lang.Error: Unresolved compilation problem:
      Invalid escape sequence (valid ones are  \b  \t  \n  \f  \r  \"  \'  \\ )

      at JServe.main(JServe.java:20)
brianw13aAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RoonaanCommented:
Try:

String regPattern = "([0-4[^2]][0-9][0-9][0-9][0-9][1-9])(\\.[0-9][0-5])?";

-r-

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
brianw13aAuthor Commented:
That seemed to do the trick - does it need to be escaped twice or is there some other secret?

Thanks
RoonaanCommented:
No it is not realy a secret.

Your regexp string is ([0-4[^2]][0-9][0-9][0-9][0-9][1-9])(\.[0-9][0-5])?

however to store it in a Java String you need to escape certain characters to have them parsed right. The backslash itself is one of those characters. When you would wanted to have a string which contains a single backslash only, you would have used "\\".

-r-
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.