Here you can find the source of isNumeric(String as_argument)
Parameter | Description |
---|---|
as_argument | given argument |
public static final boolean isNumeric(String as_argument)
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { /** only contains digital chars. */ public static final String sNUMERIC_PATTERNS[] = { "^(\\d)*$" }; /**//from w ww . ja v a 2 s . co m * check if given argument is numeric. * * @param as_argument * given argument * @return if given argument is numeric,return true, otherwise false */ public static final boolean isNumeric(String as_argument) { boolean return_value = isOneMatched(sNUMERIC_PATTERNS, as_argument); return return_value; } /** * check if the "as_searchedChars" argument matches one of all regular * expression "as_regExp_patterns". * * @param as_regExp_patterns * all regular expressions * @param as_searchedChars * chars to be searched. * @return if the "as_searchedChars" argument matches one of all regular * expression "as_regExp_patterns", return true, otherwise false */ public static final boolean isOneMatched(String[] as_regExp_patterns, String as_searchedChars) { boolean return_value = false; Pattern apattern[] = new Pattern[as_regExp_patterns.length]; Matcher amatcher[] = new Matcher[as_regExp_patterns.length]; for (int i = 0; i < as_regExp_patterns.length; i++) { apattern[i] = Pattern.compile(as_regExp_patterns[i]); amatcher[i] = apattern[i].matcher(as_searchedChars); } for (int i = 0; i < amatcher.length; i++) { if (amatcher[i].find()) { return_value = true; break; } } return return_value; } }