Top: Library add-ons: pstringx
This module provides extra string manipulation utilites that were not included
in the library core.
This module is not part of PTypes. You are free to use and/or modify it. Download the module:
#include <pstringx.h> USING_PTYPES string trim(string s); string implode(const string& glue, const variant& array); variant explode(const string& separator, const string& s); variant explode(char separator, const string& s); string uppercase(const string& s);
string trim(string s) - removes leading and trailing
whitespace characters (below code 0x20 inclusive) from the string and returns
the resulting string. This function can effectively detect if there are no whitespace
characters to remove and bypass memory allocation for the resulting string.
string implode(const string& glue, const variant& array) - 'assembles' the array items into a string placing the glue string between items. Each array item regardless of its type is being converted to a string. This function can be used, for example, to produce comma-separated lists.
variant explode(const string& separator, const string& s) - breaks the string s into separate items using the separator string and returns an array of strings. Separator is not included in the resulting items. This function is an inverse of implode().
variant explode(char separator, const string& s) - a faster version of explode() that accepts a single-character separator.
string uppercase(const string& s) - converts all ASCII-7 lowercase characters to upper-case.
See also: String