regex Header
Regular expressions library
Functions
Algorithms
regex_replace()
info
regex_replace(theString, regexVariable, replacementElement)
_, Here, regexVariable means the Regular Expression which has be replaced
replaces occurrences of a regular expression with formatted replacement text
string str; // Hello World
getline(cin, str);
regex r("\\s+"); // "\\s+" consists of all white spaces 'tabs' or ' ' or ' '
str = regex_replace(str, r, ""); //👉 replaces all "\\s+" with "" (no space)
cout << str << endl; //prints "HelloWorld"
regex_match()
- attempts to match a regular expression to an entire character sequence
regex_search()
- attempts to match a regular expression to any part of a character sequence