Regular Expressions: Matching Dots only

Problem:

Match only dots in the following expressions in the output. Any character matched other than dot is illegal and won't make your regular expressions correct.

Output:







Solution:


\.
Side comments: Yes, simply. This is the solution. There is the concept of a wildcard, which is represented by the . (dot) metacharacter, and can match any single character (letter, digit, whitespace, everything). You may notice that this actually overrides the matching of the period, so in order to specifically match a period, you need to escape the dot by using a slash \. accordingly.


No comments :

Post a Comment

Follow Me

If you like our content, feel free to follow me to stay updated.

Subscribe

Enter your email address:

We hate spam as much as you do.

Upload Material

Got an exam, project, tutorial video, exercise, solutions, unsolved problem, question, solution manual? We are open to any coding material. Why not upload?

Upload

Copyright © 2012 - 2014 Java Problems  --  About  --  Attribution  --  Privacy Policy  --  Terms of Use  --  Contact