/**
 * Created by Tony on 2017/7/5.
 * 字符串工具类简化版本
 */

let stringUtil = {
    isEmptyString: function(str) {
        let rst = false;
        if (str === null || str === undefined) {
            rst = true;
        } else if (typeof str) {
            let reg = /^\s*$/;
            rst = reg.test(str);
        }
        return rst;
    },
    replaceAll: function (targetStr, FindText, RepText) {
        let regExp = new RegExp(FindText, "gm");
        return targetStr.replace(regExp, RepText);
    },
    convertStrToBoolean: function(str) {
        let rst = false, me = this;
        if (!me.isEmptyString(str)) {
            let upperStr = str.toUpperCase();
            if (upperStr === 'T' || upperStr === 'Y' || upperStr === 'YES' || upperStr === 'TRUE') {
                rst = true;
            }
        }
        return rst;
    }
};
