zoukankan      html  css  js  c++  java
  • 廖雪峰官网学习js 字符串

    操作字符串:

      length()           长度

      totoLowerCase()  小写 

      toUpperCase()      大写

      trim()            移除空白

      charAt(n)           索引  也可以[ ]

      indexOf(substring,start) 子序列位置

      substring(from, to)     切片 小的参数为第一个参数

      slice(start, end)       切片 参数是负数时 与字符串长度相加 再切片

      substr                                 切片 参数是负数时 与字符串长度相加 结果为第一个参数

      split(delimiter, limit)            分割

      search(regexp)                   从头开始匹配,返回匹配成功的第一个位置(g无效)

      .match(regexp)                    全局搜索,如果正则中有g表示找到全部,否则只找到第一个。

    replace(regexp, replacement)     替换,正则中有g则替换所有,否则只替换第一个匹配项,

                                         $数字:匹配的第n个组内容;
                                         $&:当前匹配的内容;
                                         $`:位于匹配子串左侧的文本;
                                         $':位于匹配子串右侧的文本
                                         $$:直接量$符号
  • 相关阅读:
    HTML5 新标签
    lAMBDA表达式剖析
    whitespace 属性设置如何处理元素内的空白。
    "~/" asp.net 表示路径的方法
    ASP.NET Session详解
    关于CSS Selector的优先级
    关于汉字转拼音
    ChildActionOnly + ActionName的用法
    html中的caption是什么用
    window.location.href location.href parent.location.href
  • 原文地址:https://www.cnblogs.com/koushuige/p/8214447.html
Copyright © 2011-2022 走看看