Android Regex Match getNumber(String string)

Here you can find the source of getNumber(String string)

Description

get Number

Declaration

public static int getNumber(String string) 

Method Source Code

//package com.java2s;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

    public static int getNumber(String string) {
        int result = 0;
        Matcher m;//from   ww  w  .j  ava2s  . c om
        String regEx = "[^0-9]";
        Pattern p = Pattern.compile(regEx);
        if (string != null) {
            m = p.matcher(string);
            result = Integer.valueOf(m.replaceAll("").trim());
        }
        return result;
    }
}

Related

  1. checkPattern(String pattern, String value)