Java String Extract extractNumbers(String text)

Here you can find the source of extractNumbers(String text)

Description

extract Numbers

License

Apache License

Declaration

public static String[] extractNumbers(String text) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;
import java.util.List;

public class Main {

    public static String[] extractNumbers(String text) {
        if (isEmpty(text))
            return new String[] {};
        String[] tmp = text.split("\\D");
        List<String> list = new ArrayList<String>();
        for (String s : tmp) {
            if (s.length() > 0) {
                list.add(s);//w w w  .  ja v a2  s.  com
            }
        }
        return list.toArray(new String[0]);
    }

    public static boolean isEmpty(Object object) {
        if (object == null)
            return true;
        if (object instanceof String && object.toString().length() == 0)
            return true;
        return false;
    }
}

Related

  1. extractJobId(String line)
  2. extractKeyCodes(String codes)
  3. extractLines(String data, int tabWidth)
  4. extractNoPublicDomains(String domains)
  5. extractNumberFromInput(String command)
  6. extractPacket(String serverPacket)
  7. extractParameters(String uri)
  8. extractParamsFromUriTemplateFragment(String value)
  9. extractReferences(String value)