John de Michele wrote:I haven't tested this, but you may want to try ^(?:\\w+\\.?)+$
That will also match a String like: "abc.def." (ie. a String ending with a DOT, which is not desired, if I understand the OP correctly).
Joined: Feb 25, 2006
Neh Agarwal wrote:I need to validate product version entered by the user. The allowed pattern is any alphanumeric and a dot, i.e allowed values are:
I am using the pattern as ^(\\w+.?\\w+)+$
The only problem with the ablove pattern is if the user gives only 1 digit or 1 letter, it fails to be matched
Can you please suggest a valid pattern.
Thanks, Please Help!
Correct, that is because you used \\w+ twice, so, the minimum length of a String must be 2 to be matched.
Also note that the short-hand-character-class \w matches an underscore as well. If this is not what you want, you should use the following character class:
And the following regex will do the trick:
John de Michele
Joined: Mar 09, 2009
Oops! I think you're right. I forgot about the underscore and that pesky final dot.
Joined: Feb 27, 2009
Thanks a lot, it works perfectly
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com