zoukankan      html  css  js  c++  java
  • ReverseFind的用法 ; 查找字符中最后一个字符

    转载:https://blog.csdn.net/frivolousinstant/article/details/52796922

    ReverseFind

    CString::ReverseFind
      
    ReverseFind 在一个较大的字符串中从末端开始查找某个字符
     
      CString::ReverseFind
      int ReverseFind( TCHAR ch ) const;
      返回值:
      返回此CString对象中与要求的字符匹配的最后一个字符的索引;如果没有找到需要的字符则返回-1。
     
      说明:
      此成员函数在此CString对象中搜索与一个子串匹配的最后一个字符。此函数类似于运行时函数strrchr。
      示例:// CString::ReverseFind示例:
      CString s( "abcabc" );
      ASSERT( s.ReverseFind( 'b' ) == 4 );
     
    CString——Left、Right、Find、ReverseFind
    CString::Left(intnCount)
    ——返回字符串前nCount个字符的字符串
    example:
      CString str(_T("Shop,车间"));
      str = str.Left(4);
    结果:str="Shop";
     
    CString::Right(int nCount)
    ——返回字符串后nCount个字符的字符串
    example:
      CString str(_T("Shop,车间"));
      str = str.Right(2);
    结果:str="车间";
     
    CString::Find(_T(","))
    返回“,”在字符串中的索引值
    example:
     CString str(_T("Shop,车间"));
      int idex = str.Find(_T(","));
    此时:idex=4;
     
    宗:要想获得“,”右侧内容
    str = str.Right(str.GetLength()-1-str.Find(_T(",")));
    其中:
    str.GetLength()=7;
    -1排除“,”
    -str.Find(_T(","))排除“,”前的所有字
     
    CString::ReverseFind
      int ReverseFind( TCHAR ch ) const;
      返回值:
      返回此CString对象中与要求的字符匹配的最后一个字符的索引;如果没有找到需要的字符则返回-1。
      参数: ch 要搜索的字符。
      说明:
      此成员函数在此CString对象中搜索与一个子串匹配的最后一个字符。此函数类似于运行时函数strrchr。
      示例:// CString::ReverseFind示例:
      CString s( "abcabc" );
      ASSERT( s.ReverseFind( 'b' ) == 4 );
    CString::Left(intnCount)
    ——返回字符串前nCount个字符的字符串
    example:
      CString str(_T("Shop,车间"));
      str = str.Left(4);
    结果:str="Shop";
     
    CString::Right(int nCount)
    ——返回字符串后nCount个字符的字符串
    example:
      CString str(_T("Shop,车间"));
      str = str.Right(2);
    结果:str="车间";
     
    CString::Find(_T(","))
    返回“,”在字符串中的索引值
    example:
     CString str(_T("Shop,车间"));
      int idex = str.Find(_T(","));
    此时:idex=4;
     
    宗:要想获得“,”右侧内容
    str = str.Right(str.GetLength()-1-str.Find(_T(",")));
    其中:
    str.GetLength()=7;
    -1排除“,”
    -str.Find(_T(","))排除“,”前的所有字
     
    CString::ReverseFind
      int ReverseFind( TCHAR ch ) const;
      返回值:
      返回此CString对象中与要求的字符匹配的最后一个字符的索引;如果没有找到需要的字符则返回-1。
      参数: ch 要搜索的字符。
      说明:
      此成员函数在此CString对象中搜索与一个子串匹配的最后一个字符。此函数类似于运行时函数strrchr。
      示例:// CString::ReverseFind示例:
      CString s( "abcabc" );
      ASSERT( s.ReverseFind( 'b' ) == 4 );
  • 相关阅读:
    IT小小鸟读书笔记2
    第五周读书笔记
    JSON Schema 入门指南【Java后端使用】
    win10装多个MySQL(MySQL 8.0免安装版)
    记一些实习生问我的问题
    JAVA项目(maven)使用钉钉SDK(获取token、用户等)
    从项目开始的前端开发学习
    从项目开始的Java开发学习
    HBuilderX 5+APP MUI 入门
    项目部署各种配置
  • 原文地址:https://www.cnblogs.com/MCSFX/p/12655583.html
Copyright © 2011-2022 走看看