Java examples for java.util.regex:Match Number
is Scientific number by Regex
import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main{ /*from w w w. j av a 2 s . c o m*/ public final static String SCIENTIFIC_A = "^[-+]?(\\d+(\\.\\d*)?|\\.\\d+)([eE]([-+]?([012]?\\d{1,2}|30[0-7])|-3([01]?[4-9]|[012]?[0-3])))$"; public static boolean isScientific(String str) { if (StrisNull(str)) return false; return Regular(str, RegexHelper.SCIENTIFIC_A); } public static synchronized boolean StrisNull(String str) { return null == str || str.trim().length() <= 0 ? true : false; } private static boolean Regular(String str, String pattern) { if (null == str || str.trim().length() <= 0) return false; Pattern p = Pattern.compile(pattern); Matcher m = p.matcher(str); return m.matches(); } }