troubleshooting Question

how to do Java pattern matching for literal "." and "/"?

Avatar of summer_soccer
summer_soccer asked on
Java
8 Comments1 Solution632 ViewsLast Modified:
Hi,

I am new to Java pattern matching though I used Perl regular expression before. I am using the Pattern and Matcher classes to match string patterns.

Now suppose I have an input string like this,
min/avg/max = 39.0/272.5/506.0 ms
    I want to match the 272.5 and then later ms, and save "272.5 ms" into a String object.
I wrote something like
      Pattern pattern3 = Pattern.compile("{\d+\.\d*/}{2}(\d+\.\d*)");
to match "39.0/272.5/506.0", but it always had build errors.
It seems "\." and "/" would not match the literal "." and "/".

Can anyone tell me what is wrong with my code:
      Pattern pattern3 = Pattern.compile("{\d+\.\d*/}{2}(\d+\.\d*)");
?
Thanks a lot:)
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros