Remove range of characters

Web Site  Methods

 
Str::DeleteLeft
 
Str& DeleteLeft (CPOS count)

Removes the first count characters from the string. If count is greater than the string length, the string is emptied completely. For convenience, returns a reference to self.

Example:

   Str r (_T("AlpHAbet"));
   r.DeleteLeft(1);
   printf("%s\n", (const STRCHAR*) r); // Will print lpHAbet
   r.DeleteRight(2);
   printf("%s\n", (const STRCHAR*) r); // Will print lpHAb
   r.Delete(2, 2);
   printf("%s\n", (const STRCHAR*) r); // Will print lpb

 

 
Str::DeleteRight
 
Str& DeleteRight (CPOS count)

Removes the last count characters from the string. If count is greater than the string length, the string is emptied completely. For convenience, returns a reference to self.

See DeleteLeft for example.

 

 
Str::Delete
 
Str& Delete (CPOS start, CPOS count = 1)

Removes count characters starting at 0-based position start. If count is greater than the number of characters remaining from start to the end of the string, the string is truncated at position start. For convenience, returns a reference to self.

See DeleteLeft for example.

 

See also: Trimming / case / miscellaneous