Regex for not empty and not whitespace

In my understanding you want to match a non-blank and non-empty string, so the top answer is doing the opposite. I suggest: (.|\s)*\S(.|\s)* This matches any string containing at least one non-whitespace character (the \S in the middle). It can be preceded and followed by anything, any character or whitespace sequence (including new lines): (.|\s)*. … Read more

What is the symbol for whitespace in C?

There is no particular symbol for whitespace. It is actually a set of few characters which are: ‘ ‘ space ‘\t’ horizontal tab ‘\n’ newline ‘\v’ vertical tab ‘\f’ form feed ‘\r’ carriage return Use isspace standard library function from ctype.h if you want to check for any of these white-spaces. For just a space, … Read more

changing the delimiter for cin (c++)

It is possible to change the inter-word delimiter for cin or any other std::istream, using std::ios_base::imbue to add a custom ctype facet. If you are reading a file in the style of /etc/passwd, the following program will read each :-delimited word separately. #include <locale> #include <iostream> struct colon_is_space : std::ctype<char> { colon_is_space() : std::ctype<char>(get_table()) {} … Read more

How can I trim trailing whitespace in Visual Studio 2012 on save?

There are at least two extensions that can do this. One is CodeMaid which explicitly will trim trailing blanks on save, and the other is Productivity Power Tools which can run the Format Document automatically on save. To add an extension from within Visual Studio 2012, select menu Tools → Extensions and Updates…. In the … Read more

How to print variables without spaces between values [duplicate]

Don’t use print …, (with a trailing comma) if you don’t want spaces. Use string concatenation or formatting. Concatenation: print ‘Value is “‘ + str(value) + ‘”‘ Formatting: print ‘Value is “{}”‘.format(value) The latter is far more flexible, see the str.format() method documentation and the Formatting String Syntax section. You’ll also come across the older … Read more