| 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 ]
|
 |
 |
|
|
subject: trouble with regex
|
|
|