Check if string is empty or all spaces in C#

If you have .NET 4, use the string.IsNullOrWhiteSpace method: if(string.IsNullOrWhiteSpace(myStringValue)) { // … } If you don’t have .NET 4, and you can stand to trim your strings, you could trim it first, then check if it is empty. Otherwise, you could look into implementing it yourself: .Net 3.5 Implementation of String.IsNullOrWhitespace with Code Contracts

Ruby split by whitespace

This is the default behavior of String#split: input = <<-TEXT aa bbb cc dd ee TEXT input.split Result: [“aa”, “bbb”, “cc”, “dd”, “ee”] This works in all versions of Ruby that I tested, including 1.8.7, 1.9.3, 2.0.0, and 2.1.2.

How to preserve whitespace indentation of text enclosed in HTML tags excluding the current indentation level of the tag in the document?

Indenting With Comments Since browsers ignore comments, you can use them to indent your pre tag contents. Solution <html> <body> <main> Here is my code with hack: <pre> <!– –>def some_function <!– –> return ‘Hello, World!’ <!– –>end </pre> Here is my code without hack: <pre> def some_function return ‘Hello, World!’ end </pre> </main> <body> … Read more

c# Fastest way to remove extra white spaces

The fastest way? Iterate over the string and build a second copy in a StringBuilder character by character, only copying one space for each group of spaces. The easier to type Replace variants will create a bucket load of extra strings (or waste time building the regex DFA). Edit with comparison results: Using http://ideone.com/NV6EzU, with … Read more

Remove the Extra Whitespace Surrounding Iframes?

Having just seen your fiddle your issue is because you are using display:inline-block. This takes whitespace in your html into account. display:inline-block is notorious for being difficult and has dodgy browser support. Option 1: Try removing the white space in your html can sometimes sort the problem. Option 2: Using a different display property such … Read more

How to show/reveal hidden or invisible characters in NetBeans?

This feature was missing for a long time—a feature request was created on November 1999 and it was finally implemented on August 2010 (NetBeans 6.10). You can enable/disable it at “View → Show Non-printable Characters“. Bug history As of NetBeans 7.0.1, the definition for “non-printable” seems to include tabs and carriage returns but not regular … Read more

Why does HTML require that multiple spaces show up as a single space in the browser?

Spaces are compacted in HTML because there’s a distinction between how HTML is formatted and how it should be rendered. Consider a page like this: <html> <body> <a href=”https://stackoverflow.com/questions/433493/mylink”>A link</a> </body> </html> If the HTML was indented using spaces for example, the link would be preceded by several spaces.