Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2007

Tip: Looking for answers? Try searching our database.

Regualr Expression Puzzle

Thread view: 
Ken - 21 Feb 2007 16:18 GMT
Here's my pattern: "\\b[A-Z]([A-Z0-9]|([+-_/&](?=[A-Z0-9])))+\\b"

This pattern finds the string F1.3 . For the life of me I can't figure
out how the dot gets sucked in. Seems like it should find F1 . Can
someone explain?

Ken
Ben - 21 Feb 2007 16:47 GMT
> Here's my pattern: "\\b[A-Z]([A-Z0-9]|([+-_/&](?=[A-Z0-9])))+\\b"
>
[quoted text clipped - 3 lines]
>
> Ken

"[+-_/&]" is the set '+' to '_' plus '/' plus '&'. I'm not sure what you
are doing but you probably mean "[-+_/&]" .
Oliver Wong - 21 Feb 2007 16:49 GMT
> Here's my pattern: "\\b[A-Z]([A-Z0-9]|([+-_/&](?=[A-Z0-9])))+\\b"
>
> This pattern finds the string F1.3 . For the life of me I can't figure
> out how the dot gets sucked in. Seems like it should find F1 . Can
> someone explain?

Did you mean:

"\\b[A-Z]([A-Z0-9]|([+\\-_/&](?=[A-Z0-9])))+\\b"

?

   - Oliver
ultimadj - 21 Feb 2007 21:47 GMT
> Here's my pattern: "\\b[A-Z]([A-Z0-9]|([+-_/&](?=[A-Z0-9])))+\\b"
>
[quoted text clipped - 3 lines]
>
> Ken

Hey Ken,
The period character is 0x46. In your expression, you stated '[+-_'
which means "match any character between '+' (0x43) and '_' (0x95)".
Since '.' (0x46) is within this range, it gets matched. '-' and '+'
should be escaped, though switching the order like Oliver did
obviously works as well.

Here's a great resource for understanding how the regex engines work:
http://www.regular-expressions.info

If this is helpful, please rate my post. :)

:D avid


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.