Android Regex Compile regexCompile(String regex, String str)

Here you can find the source of regexCompile(String regex, String str)

Description

regex Compile

Declaration

public static String[] regexCompile(String regex, String str) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static String[] regexCompile(String regex, String str) {
        String[] strs = new String[0];

        Pattern p = Pattern.compile(regex);
        Matcher m = p.matcher(str);
        if (m.find() && m.groupCount() > 0) {
            strs = new String[m.groupCount()];
            for (int i = 0; i < m.groupCount(); i++) {
                strs[i] = m.group(i + 1);
            }//from  w  ww  .j  a  va2 s.c o  m
        }

        return strs;
    }
}