Solved

Regular Expressions

Posted on 2008-10-18
5
253 Views
Last Modified: 2013-11-23
hello experts,

i've been given the following regular expression "\\.\\d+|\\d+(?:\\.\\d+)?|[+-/*()%^]|\\w{3,4}|[a-zA-Z]" and im having a little trouble decoding it.

from my understanding of RE's (which isnt very much), this expression is split up into four types/categories. "[+-/*()%^]" being the normal chars, "\\w{3,4}" i would think are words of 3 or 4 letters, "[a-zA-Z]" being a letter of the alphabet, however i have absolutely no idea what the first two categories ("\\.\\d+|\\d+(?:\\.\\d+)?") represent. im guessing it has to do with numerical float values, but other then that no clue.

anyone have any idea?

cheers
0
Comment
Question by:gem56
  • 3
  • 2
5 Comments
 
LVL 11

Expert Comment

by:miqrogroove
ID: 22751216
\\.\\d+
This is a literal period, followed by one or more digits.

\\d+(?:\\.\\d+)?
This one I'm a bit confused about myself.  If I can give you a solid intrepretation I will follow up.
0
 
LVL 11

Accepted Solution

by:
miqrogroove earned 125 total points
ID: 22751224
\\d+(?:\\.\\d+)?
One or more digits followed optionally by: a literal period and one or more digits.

The syntax (?:) creates a non-backreferenced grouping, which is done only for speed optimization.

Enjoy!
0
 

Author Comment

by:gem56
ID: 22751228
thanks mate.

by the looks of it "\\d+(?:\\.\\d+)?" will probably translate to <digit>.<more digits> so looks like its just a formatting thing so it matches both "0.45" and ".45". any chance you could confirm?

cheers
0
 
LVL 11

Expert Comment

by:miqrogroove
ID: 22751235
See my second message ;)

"\\d+(?:\\.\\d+)?" will match "0.45" and not ".45"
0
 

Author Comment

by:gem56
ID: 22751302
yep, beat me to the post :P

thanks champ

0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
windows explorer path to command prompt 5 44
MySQL  on Tomcat 8 45
How to determine if a string is a valid SHA value 7 32
eclipse console opening separately 2 19
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This video teaches viewers about errors in exception handling.

773 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