Solved

Regular Expressions

Posted on 2008-10-18
5
252 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

914 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now