Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to create this pattern

Posted on 2011-04-28
5
Medium Priority
?
292 Views
Last Modified: 2012-06-27
First this is for Java usage.

I am trying to create a pattern to match any string to have the format ddd-dd-ddd first 10 characters and it can or cannot have any character or characters followed. In the pattern said above :
d = digit
-  = hyphen (it is a fixed character)
Example strings this pattern should match:
345-11-333
453-22-4332
233-44-222g
334-53-223*7kjkjd

etc.
0
Comment
Question by:prain
  • 2
  • 2
5 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 35486999
"\\d{3}-\\d{2}-\\d{3}.*" should be OK
0
 
LVL 47

Expert Comment

by:for_yan
ID: 35487005
0
 

Author Closing Comment

by:prain
ID: 35487040
Thanks. That's what I missed in my attempts - the . (dot).
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35487051
:)
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month10 days, 3 hours left to enroll

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question