#include <Regex.h>
It provides support for POSIX extended regular expressions in both case sensitive and case insensitive modes.
Static Public Methods | |
| int | find (const std::string &haystack, const std::string &needle, bool ignoreCase=false, int startIndex=0) |
| Find needle in haystack. | |
| std::string | replace (const std::string &haystack, const std::string &needle, const std::string &replacement, bool ignoreCase=false, int max=-1) |
| Replace needle with replacement in haystack. | |
| void | tokenize (const std::string &str, const std::string ®ex, List< std::string > &result, bool ignoreCase=false, int max=-1) |
| Split a string by a regular expression. | |
| List< std::string > | tokenize (const std::string &str, const std::string ®ex, bool ignoreCase=false, int max=-1) |
| Split a string by a regular expression. | |
|
||||||||||||||||||||
|
Find needle in haystack.
|
|
||||||||||||||||||||||||
|
Replace needle with replacement in haystack. Needle is a regular expression complying to the POSIX extended regex specification. Replacement may contain escaped sequences '\0' to '\9' that are replaced with the respective substring matches. '\0' means the whole match, '\1' means the first substring etc.
Example:
//replace "_text_" with "{text}" in str
str = replace(str,"_(.+)_","{\1}");
//replace "http://www.foo.com/" with [www.foo.com]
str = replace(str,"http://(.+)([[:blank:][:punct:]])","[\1]\2");
//replace "email@host.com" with "mailto:email@host.com"
str = replace(str,"[[:alnum:].-]+@[[:alnum:].-]+[a-z]","mailto:\0");
|
|
||||||||||||||||||||
|
Split a string by a regular expression.
|
|
||||||||||||||||||||||||
|
Split a string by a regular expression.
|