LOGO OA教程 ERP教程 模切知识交流 PMS教程 CRM教程 开发文档 其他文档  
 
网站管理员

substr方法

admin
2010年7月23日 15:48 本文热度 5303
  basic_string::substr
  basic_string substr(size_type _off = 0,size_type _count = npos) const;
  功能:从一个字符串复制一个从指定位置开始,并具有指定长度的子字符串。
  参数
  _off
  所需的子字符串的起始位置。字符串中第一个字符的索引为 0,默认值为0.
  _count
  复制的字符数目
  返回值
  一个子字符串,从其指定的位置开始
  备注
  如果 length 为 0 或负数,将返回一个空字符串。如果没有指定该参数,则子字符串将延续到字符串的结尾。
  示例
  下面的示例阐释了 substr 方法的用法。
  function substrdemo(){
  var s, ss; //declare variables.
  var s = "the rain in spain falls mainly in the plain.";
  ss = s.substr(12, 5); //get substring.
  return(ss); // returns "spain".
  ----------------------------------------------crazyghost_von补充-----------------------------------------------------------------------
  s.substr(12)的结果是 spain falls mainly in the plain.
  ----------------------------------------------------------------------------------------------------------------------------------------------
  code : c++中 的代码如下
  // basic_string_substr.cpp
  // compile with: /ehsc
  #include <string>
  #include <iostream>
  int main( )
  {
  using namespace std;
  string str1 ("heterological paradoxes are persistent.");
  cout << "the original string str1 is: \n " << str1
  << endl << endl;
  basic_string <char> str2 = str1.substr ( 6 , 7 );
  cout << "the substring str1 copied is: " << str2
  << endl << endl;
  basic_string <char> str3 = str1.substr ( );
  cout << "the default substring str3 is: \n " << str3
  << "\n which is the entire original string." << endl;
  输出结果:
  the original string str1 is:
  heterological paradoxes are persistent.
  the substring str1 copied is: logical
  the default substring str3 is:
  heterological paradoxes are persistent.
  which is the entire original string.
  }
  在oracle中的用法:
  substr(:new.flagstatus,17,1)
  其中第一一次是是 ( 串,开始,长度)返回子串。

该文章在 2010/7/23 15:48:27 编辑过
相关文章
正在查询...
点晴ERP是一款针对中小制造业的专业生产管理软件系统,系统成熟度和易用性得到了国内大量中小企业的青睐。
点晴PMS码头管理系统主要针对港口码头集装箱与散货日常运作、调度、堆场、车队、财务费用、相关报表等业务管理,结合码头的业务特点,围绕调度、堆场作业而开发的。集技术的先进性、管理的有效性于一体,是物流码头及其他港口类企业的高效ERP管理信息系统。
点晴WMS仓储管理系统提供了货物产品管理,销售管理,采购管理,仓储管理,仓库管理,保质期管理,货位管理,库位管理,生产管理,WMS管理系统,标签打印,条形码,二维码管理,批号管理软件。
点晴免费OA是一款软件和通用服务都免费,不限功能、不限时间、不限用户的免费OA协同办公管理系统。
Copyright 2010-2024 ClickSun All Rights Reserved