zoukankan      html  css  js  c++  java
  • String 对象-->substr() 方法

    1.定义和用法

      substr() 方法可在字符串中抽取从 开始 下标开始的指定数目的字符。

      语法:

        string.substr(start,length)

        参数:

          start:提取开始下标

          length:提取长度,如果省略了该参数,那么返回从 stringObject 的开始位置到结尾的字串。

      举例:提取句子”Blue“

    var str='Mr Blue has a blue house and a blue car'
    var str1 = str.substr(3,4) /*字符串本身不会改变,需要新的变量接受它*/
    console.log(str1)

      输出:

        

  • 相关阅读:
    Title
    Title
    Title
    Title
    Python生成随机验证码
    Time模块和datetime模块
    For循环的实质
    Python函数
    集合set
    字符串内置方法的使用
  • 原文地址:https://www.cnblogs.com/abner-pan/p/12701271.html
Copyright © 2011-2022 走看看