zoukankan      html  css  js  c++  java
  • Ext.String 方法

    1.Ext.String.htmlEncode(value);  编码字符串,对其中特殊字符进行转义

    xt.String.htmlEncode("hello'world");    //"hello'world"

    2.Ext.String.htmlDecode(value);  解码字符串,对其中的转义字符进行还原

    Ext.String.htmlDecode("hello'world");    //"hello'world"

    3.Ext.String.urlAppend(url,string)  追加内容到查询字符中,?相连

    Ext.String.urlAppend("www.baidu.com","a=1");    //"www.baidu.com?a=1"

    4.Ext.String.trim(string)  去掉字符串开头和结尾位置的空格

    Ext.String.trim(" hello world ");    //"hello world"

    5.Ext.String.capitalize(string)  首字母大写

    Ext.String.capitalize("hello");    //"Hello"

    6.Ext.String.ellipsis(value,length,word)  截断字符串并在结尾处添加省略号  value 原始字符串 length 保留长度 word 设置为true则试图保留完整单词

    Ext.String.ellipsis("my name is shi",3,false);    //"..."
    Ext.String.ellipsis("my name is shi",3,true);    //"..."
    Ext.String.ellipsis("my name is shi",6,false);    //"my ..."
    Ext.String.ellipsis("my name is shi",6,true);    //"my..."
    Ext.String.ellipsis("my name is shi",8,false);    //"my na..."
    Ext.String.ellipsis("my name is shi",8,true);    //"my..."

    7.Ext.String.escapeRegex(string)  将原始字符串中的-.*+?^${}()[]进行替换

    Ext.String.escapeRegex("hello -.*+?^${}()[]");    //"hello -.*+?^${}()[]"

    8.Ext.String.toggle(string,value,other)  对比两个字符串是否相等,相等返回other,不相等返回value

    Ext.String.toggle("abc","abc","相等");    //"相等"
    Ext.String.toggle("abc","cba","相等");    //"cba"

    9.Ext.String.leftPad(string,size,[character])  在字符串左边填充指定字符串

    Ext.String.leftPad("12 3",5,"0000");    //"000012 3"

    10.Ext.String.format(string,value1,value2)  定义带标记的字符串,并用传入的字符替换标记。 每个标记必须是唯一的,而且必须要像{0},{1}...{n}这样地自增长

    var cls = 'my-class', text = 'Some text';
    Ext.String.format('<div class="{0}">{1}</div>', cls, text);    //'<div class="my-class">Some text</div>'

      

  • 相关阅读:
    hdu 2546 饭卡
    poj 2262 Goldbach's Conjecture
    poj 1287 Networking
    poj 2377 Bad Cowtractors
    poj 1789 Truck History
    poj 2349 Arctic Network
    poj 1258 Agri-Net
    acdream 20140730 D题
    hdu 1012 素数判定
    hdu 2098 分拆素数和
  • 原文地址:https://www.cnblogs.com/glsqh/p/5892767.html
Copyright © 2011-2022 走看看