is Money String by Regex - Java java.util.regex

Java examples for java.util.regex:Match Number

Description

is Money String by Regex

Demo Code


//package com.java2s;

import java.util.regex.Pattern;

public class Main {
    private static Pattern PATTERN_MONEY = Pattern
            .compile("[\\d]+|[\\d]+[.]{1}[1-9]{1,2}|[\\d]+[.]{1}[0-9]{1}[1-9]{1}");

    public static boolean isMoney(String money) {
        if (money == null)
            return false;
        else/*w w  w. j  a v a  2s. c om*/
            return PATTERN_MONEY.matcher(money).matches();
    }
}

Related Tutorials