How can I trim leading and trailing white space?
As of R 3.2.0 a new function was introduced for removing leading/trailing white spaces: trimws() See: Remove Leading/Trailing Whitespace
As of R 3.2.0 a new function was introduced for removing leading/trailing white spaces: trimws() See: Remove Leading/Trailing Whitespace
Basically you need to escape it twice, because it’s escaped locally and then on the remote end. There are a couple of options you can do (in bash): scp user@example.com:”‘web/tmp/Master File 18 10 13.xls'” . scp user@example.com:”web/tmp/Master\ File\ 18\ 10\ 13.xls” . scp user@example.com:web/tmp/Master\\\ File\\\ 18\\\ 10\\\ 13.xls .
Use list comprehension — simpler, and just as easy to read as a for loop. my_string = “blah, lots , of , spaces, here ” result = [x.strip() for x in my_string.split(‘,’)] # result is [“blah”, “lots”, “of”, “spaces”, “here”] See: Python docs on List Comprehension A good 2 second explanation of list comprehension.
I assume your questions is with regards to Java code. If that’s the case, you don’t actually need any extra plugins to accomplish 1). You can just go to Preferences -> Java -> Editor -> Save Actions and configure it to remove trailing whitespace. By the sounds of it you also want to make this … Read more
For end of line use: git diff –ignore-space-at-eol Instead of what are you using currently: git diff -w (–ignore-all-space) For start of line… you are out of luck if you want a built in solution. However, if you don’t mind getting your hands dirty there’s a rather old patch floating out there somewhere that adds … Read more
This is fastest way I know of, even though you said you didn’t want to use regular expressions: Regex.Replace(XML, @”\s+”, “”); Crediting @hypehuman in the comments, if you plan to do this more than once, create and store a Regex instance. This will save the overhead of constructing it every time, which is more expensive … Read more
Something in the lines of myString.split(“\\s+”); This groups all white spaces as a delimiter. So if I have the string: “Hello[space character][tab character]World” This should yield the strings “Hello” and “World” and omit the empty space between the [space] and the [tab]. As VonC pointed out, the backslash should be escaped, because Java would first … Read more
The str.split() method without an argument splits on whitespace: >>> “many fancy word \nhello \thi”.split() [‘many’, ‘fancy’, ‘word’, ‘hello’, ‘hi’]
VS Code 1.6.0 and Greater As mentioned by aloisdg below, editor.renderWhitespace is now an enum taking either none, boundary or all. To view all whitespaces: “editor.renderWhitespace”: “all”, Before VS Code 1.6.0 Before 1.6.0, you had to set editor.renderWhitespace to true: “editor.renderWhitespace”: true
st.replaceAll(“\\s+”,””) removes all whitespaces and non-visible characters (e.g., tab, \n). st.replaceAll(“\\s+”,””) and st.replaceAll(“\\s”,””) produce the same result. The second regex is 20% faster than the first one, but as the number consecutive spaces increases, the first one performs better than the second one. Assign the value to a variable, if not used directly: st = … Read more