Here you can find the source of find(String _sSourceString, String _sReg, int group)
public static String find(String _sSourceString, String _sReg, int group)
//package com.java2s; import java.io.UnsupportedEncodingException; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static String find(String _sSourceString, String _sReg) { return find(_sSourceString, _sReg, 0); }//from w ww . j a v a 2 s.c o m public static String find(String _sSourceString, String _sReg, String _sInputEncode, String _sOutEncode) { return find(_sSourceString, _sReg, 0, "GBK", "GBK"); } public static String find(String _sSourceString, String _sReg, int group) { return find(_sSourceString, _sReg, group, "GBK", "GBK"); } /** * @param _sSourceString * @param _sReg * @param _sInputEncode * @param _sOutEncode * @return */ public static String find(String _sSourceString, String _sReg, int group, String _sInputEncode, String _sOutEncode) { if (_sSourceString == null || _sReg == null) { return null; } Matcher mat = Pattern.compile(_sReg).matcher(_sSourceString); if (mat.find()) { String result = mat.group(group); try { return new String(result.getBytes(_sInputEncode), _sOutEncode); } catch (UnsupportedEncodingException ex) { //logger.error("Invalid encoding!", ex); } } return null; } }