Remove all special characters and case from string in bash

cat yourfile.txt | tr -dc ‘[:alnum:]\n\r’ | tr ‘[:upper:]’ ‘[:lower:]’ The first tr deletes special characters. d means delete, c means complement (invert the character set). So, -dc means delete all characters except those specified. The \n and \r are included to preserve linux or windows style newlines, which I assume you want. The second …

Read more

Is this C++11 regex error me or the compiler?

Update: <regex> is now implemented and released in GCC 4.9.0 Old answer: ECMAScript syntax accepts [0-9], \s, \w, etc, see ECMA-262 (15.10). Here’s an example with boost::regex that also uses the ECMAScript syntax by default: #include <boost/regex.hpp> int main(int argc, char* argv[]) { using namespace boost; regex e(“[0-9]”); return argc > 1 ? !regex_match(argv[1], e) …

Read more

What does ?: do in regex

It indicates that the subpattern is a non-capture subpattern. That means whatever is matched in (?:\w+\s), even though it’s enclosed by () it won’t appear in the list of matches, only (\w+) will. You’re still looking for a specific pattern (in this case, a single whitespace character following at least one word), but you don’t …

Read more

Greasemonkey/ Tampermonkey @match for a page with parameters

@match only works on the protocol/scheme, host, and pathname of a URL. To trigger off the query parameters, you can either use @include or use @match and also test the URL yourself. Note that the @match approach performs faster. With @include, you can use a regex syntax. See, also Include and exclude rules. In this …

Read more