package com.test.demo.test;
public class Test {
public static Stringstr="column 1 \"sdfsdf\" type string 3";
public static void main(String[] args) {
String tmpStr =str.replace("\"","");
System.out.println(tmpStr);
tmpStr=tmpStr.trim();
int count =getSubLength(tmpStr," ");
String [] strings = tmpStr.split(" ",count+1);
if (strings.length>2)
System.out.println(strings[2]);
if (strings.length>5)
System.out.println(strings[5]);
}
/**
* 获取子串的个数
* @param rawStr:原始字符串
* @param subStr:子串
* @return
*/
public static int getSubLength(String rawStr,String subStr){
//int count=0;
//if (StringUtils.isBlank(rawStr)||StringUtils.isBlank(subStr)) return count;
int length=rawStr.length()-rawStr.replace(subStr, "").length();
return length/subStr.length();
}
}
网友评论