Java examples for java.util.regex:Match Number
check numbers by regex
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { String checkText = "java2s.com"; System.out.println(checkNum(checkText)); }/* w ww.j a v a 2 s .co m*/ /** * check numbers * * @param checkText * @return */ public static boolean checkNum(String checkText) { checkText = checkText.trim(); if (checkText.matches("\\d+")) { return true; } else { return false; } } }