Cstring -- left, right, find, reversefind

Source: Internet
Author: User
Cstring -- left, right, find, reversefind

Http://hi.baidu.com/shawmar/item/08b30afb0f32d46f3c1485ec

Cstring -- left, right, find, reversefind

Cstring: Left (intNcount)

-- Returns the ncount character string before the string

Example:

Cstring STR (_ T ("Shop, Workshop "));

STR = Str. Left (4 );

Result: Str = "Shop ";

 

Cstring: Right (INT ncount)

-- Returns the string of ncount characters after the string

Example:

Cstring STR (_ T ("Shop, Workshop "));

STR = Str. Right (2 );

Result: Str = "Workshop ";

 

Cstring: Find (_ T (","))

Returns the index value of "," in the string.

Example:

Cstring STR (_ T ("Shop, Workshop "));

Int idex = Str. Find (_ T (","));

At this time: idex = 4;

 

Zong: to obtain "," content on the right

STR = Str. Right (Str. getlength ()-1-str.find (_ T (",")));

Where:

Str. getlength () = 7;

-1 exclude ","

-Str. Find (_ T (",") exclude all words before ","

 

Cstring: reversefind

Int reversefind (tchar ch) const;

Return Value:

Returns the index of the last character that matches the required character in the cstring object. If the required character is not found,-1 is returned.

Parameter: the string to be searched.

Note:

This member function searches for the last character that matches a substring in this cstring object. This function is similar to the runtime function strrchr.

Example: // cstring: reversefind example:

Cstring S ("abcabc ");

Assert (S. reversefind ('B') = 4 );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.