zoukankan      html  css  js  c++  java
  • 【JS Note】字符串截取

    Js中字符截取常用的三个函数:slice()、substring()、substr()。

    slice():

    slice(start,[end]) 

    第一个参数代表开始位置,第二个参数代表结束位置的下一个位置。

    substring():

    substring(start,[end])

    第一个参数代表开始位置,第二个参数代表结束位置的下一个位置。

    substr():

    substr(start,[length])

    第一个参数代表开始位置,第二个参数代表截取的长度。

    注:字符串都从0开始计起

    Name: Ataw.Dev.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

    TrueName: Ataw.Dev.Core

    VersionName: 1.0.0.0

    if (config.Name) {
    
      this.TrueName = config.Name;
    
      this.VersionsName = config.Name;
    
      if (config.Name.length == 0) {
        this.NameIsNull = true;
      } else {
        this.TrueName = this.TrueName.substring(0, this.TrueName.lastIndexOf(','));
        this.TrueName = this.TrueName.substring(0, this.TrueName.lastIndexOf(','));
        this.TrueName = this.TrueName.substring(0, this.TrueName.lastIndexOf(','));
        this.VersionsName = this.VersionsName.substring(0, this.VersionsName.lastIndexOf(','));
        this.VersionsName = this.VersionsName.substring(0, this.VersionsName.lastIndexOf(','));
        this.VersionsName = this.VersionsName.substr(this.VersionsName.indexOf(',') + 1, 100);
        this.VersionsName = this.VersionsName.substr(9);
      }
    } else {
      this.NameIsNull = true;
    }
    

      

  • 相关阅读:
    豆瓣还是能学到东西的!
    Mip-Mapping很重要
    果然还是SB了
    Don't Starve,好脚本,好欢乐
    Soft Renderer的乐趣
    java classloader原理深究
    用gitolite搭建git server
    神话设计模式 --开端
    Dive into Spring framework -- 了解基本原理(二)--设计模式-part2
    Dive into Spring framework -- 了解基本原理(二)--设计模式-part1
  • 原文地址:https://www.cnblogs.com/yimi8426/p/5900359.html
Copyright © 2011-2022 走看看