Can such a thing be done?
To explain myself a bit better I need a regular expression that will
only match an empty string ("") - if there is any text in the string I
don't want it to match. Won't go into why, it would take too much
explanation!
Thanks for any help/suggestions...
Cheers,
Steve
Eric Sosman - 08 May 2006 16:55 GMT
steve.chambers@gmail.com wrote On 05/08/06 11:41,:
> Can such a thing be done?
>
> To explain myself a bit better I need a regular expression that will
> only match an empty string ("") - if there is any text in the string I
> don't want it to match. Won't go into why, it would take too much
> explanation!
Pattern empty = Pattern.compile("^$");

Signature
Eric.Sosman@sun.com
Jeffrey Schwab - 09 May 2006 22:39 GMT
> I need a regular expression that will
> only match an empty string ("") - if there is any text in the string I
> don't want it to match. Won't go into why, it would take too much
> explanation!
.{0}
steve.chambers@gmail.com - 16 May 2006 11:21 GMT
Both seem to work, not sure which is best but will probably go with the
.{0} suggestion as its meaning seems slightly more intuitive.
Thanks v. much to both of you for the helpful suggestions.