Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes trouble with regex Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "trouble with regex" Watch "trouble with regex" New topic
Author

trouble with regex

miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
i'm trying to validate this string representing money, and i want it to be like
xxxxxx
or
xxxx.n
or
xxxx.nn

so i'm using this method:
public static boolean valida(String valor)

throws NumberFormatException {

if ( valor.matches ( "[0-9] + (\\.[0-9]{1,2})" ) ) {

return true;

}

else return false;

}


but when i test, i allways get an assertion failed:


What am i doing wrong?

TiA


java amateur
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
i found it out:
should be:

[ August 23, 2005: Message edited by: miguel lisboa ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: trouble with regex