统计文本中某个字符串出现的次数
@param str
@param target
@return
下午5:33:24
968977
public static int count(String str,String target){
		int count=0; 
		int index=0; 
		while(true){ 
			index=str.indexOf(target,index+1); 
			if(index>0){ 
				count++; 
			}else{ 
				break; 
			} 
		} 
		return count; 
	}
466760
@Override
    public Time fromString(Class targetClass, String s)
    {
        if (s == null)
        {
            return null;
        }

        if (StringUtils.isNumeric(s))
        {
            return new Time(Long.parseLong(s));
        }
        Time t = Time.valueOf(s);
        return t;
    }
483235
def target_str_to_list(target_str):
    
    new_list = list()
    for target in target_str.split(','):
        target = target.strip()
        target_list = target_to_list(target)
        if target_list:
            new_list.extend(target_list)
        else:
            LOGGER.info("{0}: Invalid target value".format(target))
            return None
    return list(collections.OrderedDict.fromkeys(new_list))
1179511
private static void outputVerb(final ByteArrayOutputStream baos, final String str) {
        if (str.length() == 1) {
            baos.write(254);
            baos.write(str.toCharArray()[0]);
        } else {
            final byte[] bytes = str.getBytes(Charsets.UTF_8);
            baos.write(255);
            baos.write(str.length());
            baos.write(bytes, 0, bytes.length);
        }
    }
1304341
public void text(String str)
    {
        if (fieldNames.isEmpty() || fieldValues.isEmpty())
            return;
        
        String val = (String)fieldValues.pop();
        val += str;
        fieldValues.push(val);
    }
1238450
public static Instant parse(String str, DateTimeFormatter formatter) {
        return formatter.parseDateTime(str).toInstant();
    }
484688
public static String frontstring(final String str, final int index) {
        assertStringNotNull(str);
        if (str.length() < index) {
            String msg = "The length of the string was smaller than the index:";
            msg = msg + " str=" + str + " index=" + index;
            throw new StringIndexOutOfBoundsException(msg);
        }
        return str.substring(0, index);
    }
1251740
public static String dequote(String str, char quote)
    {
        // Is there anything to dequote?
        if (str == null)
        {
            return null;
        }

        return dequote(str, 0, str.length(), quote);
    }
12764
public static int length(String str) {
		if (StringUtils.isEmpty(str))
			return 0;
		str = str.replaceAll("([\u4e00-\u9fa5]|[，￥！？％＆＠＃＾。“”；《》‘’｜【】—…·＋－×、（）])", "  ");
		return str.length();
	}
229842
public static Character convertChar(Object target) {
        if (target instanceof JsonNode) {
            return convertChar((JsonNode) target);
        }
        return target instanceof Character ? (Character) target
                : target instanceof Number ? (char) ((Number) target).intValue()
                        : target instanceof String
                                ? target.toString().length() > 0 ? target.toString().charAt(0) : 0
                                : 0;
    }
1068831
private static int quote(final StringBuilder target, final String string, final int start) {
        int i = quoteSingle(target, string, start);
        if (i < 0) i = quoteBlock(target, string, start, -i);
        return i;
    }
98013
private String trim(final String str) {

        final int length = str.length();
        if(length == 0) {
            return str;
        }

        if(leftAlign) {
            if(str.charAt(0) != trimChar) {
                // 左端がトリム対象の文字出ない場合、処理終了
                return str;

            }

            // 左側から、trimCharに一致しない位置を探す
            for(int i=0; i < length; i++) {
                char c = str.charAt(i);
                if(c != trimChar) {
                    return str.substring(i);
                }
            }

            // 全ての文字がトリム対象の場合
            return "";

        } else {
            if(str.charAt(length - 1) != trimChar) {
                // 右端がトリム対象の文字出ない場合、処理終了
                return str;

            }

            // 右側から、trimCharに一致しない位置を探す
            for(int i=length - 1; i >= 0; i--) {
                char c = str.charAt(i);
                if(c != trimChar) {
                    return str.substring(0, i + 1);
                }
            }

            // 全ての文字がトリム対象の場合
            return "";

        }

    }
105911
public static String chop(String target) {
		if (isEmpty(target)) { return EMPTY; }
		int len = target.length(), lastIdx = -1;
		if (len >= 2 && target.charAt(len - 1) == LF && target.charAt(len - 2) == CR) {
			if (len == 2) { return EMPTY; } lastIdx = -2; 
		}
		return replace(target).afters(lastIdx).byNone().last();
	}
180565
function rtrim(str, targetStr) {
    var retStr = "";
    var regStr;

    if (typeof str != "string") {
        return retStr;
    }

    if (typeof targetStr != "string" || !targetStr) {
        targetStr = "\\s";
    }

    regStr = "(.*?)" + targetStr + "*$";
    regStr = new RegExp(regStr);

    str = str.replace(regStr, "$1");
    return str;
}
1251971
public String escapeXml(final Object target) {
        if (target == null) {
            return null;
        }
        return StringUtils.escapeXml(target);
    }
1178169
private static InputSource stringToSource(String str) {
        InputSource is = new InputSource(new StringReader(str));
        is.setEncoding("UTF-8");
        return is;
    }
25424
function pickoutValue(target, str) {
  const strDepth = str.split('.');
  const newTarget = target[strDepth[0]];
  if (newTarget === undefined) throw new Error('Cannot find the value');
  if (strDepth.length === 1) return newTarget;
  return pickoutValue(newTarget, strDepth.splice(1).join('.'));
}