1 package com.yuji.tdb.utility;
3 import java.util.regex.Pattern;
5 public class StringUtil {
6 private static Pattern ptnAlnum = Pattern.compile("[a-zA-Z0-9]");
7 private static Pattern ptnAscii = Pattern.compile("\\p{ASCII}");
9 public static String parseSubstring(String text, int length){
10 int len = text.length();
14 for (int i = 0; i < len && i < length; i++){
15 String ch = text.substring(i, i + 1);
17 if (ptnAlnum.matcher(ch).matches()){
23 else if (ptnAscii.matcher(ch).matches()){
36 return text.substring(0, pos);