替换属性
@param  {[type]}  str       [description]
@param  {Boolean} isArticle [description]
@param  {[type]}  noHead    [description]
@return {[type]}            [description]
18128
function doAttr(str, isArticle, noHead) {
    //input:## Title {:.build width="200px"}
    //output: <h2 class="build" width="200px">Title</h2>

    str = str.replace(/<(\w+)([^>]*)>([^<]+)(\s+\{:([^\&].+)\})<\/\1>/gm, function(input, tag, pre, text, idinput, attrs) {
        var attr = parseAttr(idinput, attrs);
        attr = mergeAttr(pre, attr);
        return '<' + tag + ' ' + attr + '>' + text + '</' + tag + '>';
    });
    str = str.replace(/<(\w+)>([^<]+)<(\w+)>(.+)(\s+\{:\&amp;(.+)\})/mg, function(input, parentTag, parentText, childTag, childText, idinput, attrs) {
        var attr = parseAttr(idinput, attrs);
        return '<' + parentTag + ' ' + attr + '>' + parentText + '<' + childTag + '>' + childText;
    });

    return str;
}
424632
function ( str ) {
            str = String( str );
    
            if ( str ) {
                if ( /^\s*true\s*$/.test(str) ) {
                    str = Boolean( str );
                } else if ( /^\s*false\s*$/.test(str) ) {
                    str = Boolean();
                } else if ( /^\s*-*[0-9\.]+\s*$/.test(str) ) {
                    str = Number( str );
                } else if ( /^\s*null\s*$/.test(str) ) {
                    str = null;
                } else if ( /^\s*undefined\s*$/.test(str) ) {
                    str = undefined;
                }
            }
            return str;
        }
571310
function itrim(str, targetStr) {
    var retStr = "";
    var replaced = targetStr;
    var regStr;

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

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

    regStr = new RegExp(targetStr + "+", "g");

    str = str.replace(regStr, replaced);
    return str;
}
615763
function string(str) {
  assertString(str);
  var expected = "'" + str + "'";
  return Parsimmon(function(input, i) {
    var j = i + str.length;
    var head = input.slice(i, j);
    if (head === str) {
      return makeSuccess(j, head);
    } else {
      return makeFailure(i, expected);
    }
  });
}
232598
function anagram( str, x ) {
	if ( !isString( str ) ) {
		throw new TypeError( 'anagram()::invalid input argument. First argument must be a string. Value: `' + str + '`.' );
	}
	if ( !isString( x ) ) {
		return false;
	}
	str = str.toLowerCase()
		.replace( /[^a-z0-9]/g, '' );
	x = x.toLowerCase()
		.replace( /[^a-z0-9]/g, '' );
	if ( str.length !== x.length ) {
		return false;
	}
	str = str.split( '' )
		.sort( ascending )
		.join( '' );
	x = x.split( '' )
		.sort( ascending )
		.join( '' );
	return ( str === x );
}
245916
public static String emptyToNull(String str) {
        return (str == null || str.length() == 0 ? null : str);
    }
168651
function(str) {
            var o   = parseUri.options,
            m   = o.parser.exec(str),
            uri = {},
            i   = 14;

            while (i--) if (m[i]) uri[o.key[i]] = m[i];

            if (uri[o.key[12]]) {
                uri[o.q.name] = {};
                uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
                    if ($1) uri[o.q.name][$1] = $2;
                });
            }
            // member functions
            uri.toString = toString;
            uri.validate = validate;
            uri.normalize = normalize;
            uri.contains = contains;
            uri.originOnly = originOnly;
            return uri;
        }
867445
function(str) {
  var abbrRegex = /^\-(\w+?)$/,
      fullRegex = /^\-\-(no\-)?(.+?)(?:=(.+))?$/,
      valRegex = /^[^\-].*/;

  var charMatch = abbrRegex.exec(str),
      chars = charMatch && charMatch[1].split("");

  var fullMatch = fullRegex.exec(str),
      full = fullMatch && fullMatch[2];

  var isValue = str !== undefined && (str === "" || valRegex.test(str));
  var value;
  if (isValue) {
    value = str;
  }
  else if (full) {
    value = fullMatch[1] ? false : fullMatch[3];
  }

  return {
    str: str,
    chars: chars,
    full: full,
    value: value,
    isValue: isValue
  }
}
825634
function(str) {
        var p;
        p = str.indexOf('.');
        if (p==-1) {
            return libbcmath.bc_str2num(str, 0);
        } else {
            return libbcmath.bc_str2num(str, (str.length-p));
        }

    }
1067500
function attrsStringify(node, doc, clsSet){
	let attrs = node.attrs;
	if ( !attrs ) {
		node.x = 1;
		return null;
	}

	let kvs = [];
	let objs = [];
	let cls = {};
	let staticAttrs = true;

    // 含ref属性时，自动添加$context属性，避免组件对象上下文混乱，深度slot内的标签含ref属性时特需
    attrs['@ref'] && ((attrs.ref = attrs['@ref']) > delete attrs['@ref'] );     // 支持@ref属性，转换为ref
    attrs.ref && (attrs.$context = '{=$this}');

	for ( let k in attrs ) {
		if ( (k.startsWith(options.ExpressionStart) && k.endsWith(options.ExpressionEnd)) || (k.startsWith(options.ExpressionUnescapeStart) && k.endsWith(options.ExpressionUnescapeEnd)) ) {
			// 键名是表达式，是个单纯的属性键值对象 <tag {prop} />
			let expr = util.getExpression(k);
			//expr.startsWith('(')
			objs.push(expr.startsWith('(') ? expr : expr.substring(expr.indexOf('('))); // escapeHtml(....) => (....)
			staticAttrs = false;
		}else{
			if ( attrs[k] === true ) {
				// 这是个无值的字符串属性，通常是readonly之类，在m220-syntax-ast中补充赋值的true
				kvs.push('"' + k + '": 1'); // 用1代表true
			}else{
				let ary = [];
				let espAttr = escapeAttrExpr(attrs[k].trim());				// 把【\{】和【\}】替换为两位特殊字符，避免误当表达式解析
				parseExpression(ary, espAttr);								// 解析表达式
				let expr = '(' + unescapeAttrExpr(ary.join(' + ')) + ')';	// 把【\{】和【\}】替换回来

				if ( k == 'class' ) {
					kvs.push('"' + k + '": ' + classStrToObjectString(attrs[k], doc, clsSet) );  // class="abc def {bar:!bar}" => {class:{abc:1, def:1, bar:!bar}}
				}else{
					kvs.push('"' + k + '": ' + expr);
				}

				if ( staticAttrs && attrs[k].indexOf(options.ExpressionStart) >=0 || attrs[k].indexOf(options.ExpressionUnescapeStart) >=0 ) {
					staticAttrs = false; // 键值中含表达式
				}
			}
		}
	}

	if ( staticAttrs ) {
		node.x = 1; // 这个节点的属性是静态的，后续可利用这个标记省略比较属性是否有变化
	}

	let rs = '{' + kvs.join(',') + '}';
	if ( objs.length ) {
		rs = `rpose.assign(${rs}, ${objs.join(',')})`;
	}
	return rs;
}
300870
def str_if_not_none(value):
    
    if not(value is None or isinstance(value, string_types)):
        value = str(value)

    return value
148872
function contains(str) {
    return {
        hiragana: hasHiragana(str),
        katakana: hasKatakana(str),
        kanji: hasKanji(str)
    };
}
257338
public static boolean isAllNumber(String str) {
    	boolean hasNumber = false;
		for (int i = 0; i < str.length(); i++) {
		    if (!(Character.isDigit(str.charAt(i)) || 
				str.charAt(i) == '.' || str.charAt(i) == ',' || str.charAt(i) == '%'
				|| str.charAt(i) == '$' || str.charAt(i) == '_')) {
			return false;
		    }
		    else if (Character.isDigit(str.charAt(i)))
		    	hasNumber = true;
		}
		
		if (hasNumber == true)
			return true;
		else return false;		
    }
137999
public static boolean isAllAlpha(String str) {

	if (str == null) return false;

	for (int i = str.length() - 1; i >= 0; i--) {

	    if (!Character.isLetter(str.charAt(i))) return false;
	}

	return true;
    }
531473
function vNumber(func, type, str, range) {
    let success   = true;
    let checkType = true;
    let errmsg;
    // 先验证类型
    if (!func(str)) {
      errmsg = localData.em_type({
        desc,
        str,
        type,
      });
      checkType = false;
      success = false;
    }
    // 再验证类型范围
    // if (range && range.min === undefined) {
    //   range.min = 0;
    // }
    if (range && (range.min === undefined || range.min < -NUMBER_MAX)) {
      range.min = -NUMBER_MAX;
    }
    if (range && (range.max === undefined || range.max > NUMBER_MAX)) {
      range.max = NUMBER_MAX;
    }
    if (success && checkType && range && (range.min !== undefined || range.max !== undefined)) {
      if (range && range.min !== undefined && range.min > Number(str)) {
        success = false;
      }
      if (success && range && range.max !== undefined && range.max < Number(str)) {
        success = false;
      }
      if (!success) {
        errmsg = localData.em_minmax({
          desc,
          type,
          opDesc: 'value',
          minOp : '>=',
          min   : range.min,
          maxOp : '<=',
          max   : range.max,
        });
      }
    }
    return { success, errmsg };
  }
816793
public final static boolean isMailAddress(String str)
    {
        int atIndex = str.indexOf('@');
        if ( atIndex == -1 ) {
            return false;
        }
        
        if ( ! StringUtil.isLetterOrNumeric(str, 0, atIndex) ) {
            return false;
        }
        
        int ptIndex, ptStart = atIndex + 1;
        while ( (ptIndex = str.indexOf('.', ptStart)) > 0 ) {
            if ( ptIndex == ptStart ) {
                return false;
            }
            
            if ( ! StringUtil.isLetterOrNumeric(str, ptStart, ptIndex) ) {
                return false;
            }
            
            ptStart = ptIndex + 1;
        }
        
        if ( ptStart < str.length() 
                && ! StringUtil.isLetterOrNumeric(str, ptStart, str.length()) ) {
            return false;
        }
        
        return true;
    }
808073
function isAllUpperCase (str) {
  return str
    .split("")
    .map(ch => ch.charCodeAt(0))
    .every(n => n >= 65 && n <= 90);
}