removing-whitespace

How to remove leading and trailing whitespace in a MySQL field?

痞子三分冷 提交于 2019-11-26 19:25:28
I have a table with two fields (countries and ISO codes): Table1 field1 - e.g. 'Afghanistan' (without quotes) field2 - e.g. 'AF'(without quotes) In some rows the second field has whitespace at the start and/or end, which is affecting queries. Table1 field1 - e.g. 'Afghanistan' (without quotes) field2 - e.g. ' AF' (without quotes but with that space in front) Is there a way (in SQL) to go through the table and find/replace the whitespace in field2? You're looking for TRIM . UPDATE FOO set FIELD2 = TRIM(FIELD2); A general answer that I composed from your answers and from other links and it

How to remove all white space from the beginning or end of a string?

寵の児 提交于 2019-11-26 18:39:41
How can I remove all white space from the beginning and end of a string? Like so: "hello" returns "hello" "hello " returns "hello" " hello " returns "hello" " hello world " returns "hello world" Mau String.Trim() returns a string which equals the input string with all white-spaces trimmed from start and end: " A String ".Trim() -> "A String" String.TrimStart() returns a string with white-spaces trimmed from the start: " A String ".TrimStart() -> "A String " String.TrimEnd() returns a string with white-spaces trimmed from the end: " A String ".TrimEnd() -> " A String" None of the methods modify

Why is there a pesky little space between <img> and other elements? [duplicate]

荒凉一梦 提交于 2019-11-26 17:05:18
问题 This question already has an answer here: Image inside div has extra space below the image 9 answers If a <div> or any other element follows an <img> , then a ~3px whitespace appears in between them — even if margins are zero'd. <img src="example-fractal-art.png"> <div>What is with that gap?<div> Here's what it looks like with some CSS. Now it's pretty easy to throw in display: block into the CSS and solve the problem. But why is it there? There are no computed margins, padding, borders, or

Extra space under textarea, differs along browsers

拈花ヽ惹草 提交于 2019-11-26 15:23:14
问题 There`s some extra space under textarea tag. From 1 to 4 pixels in different browsers. The markup is very simple: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <style> body { margin: 0; padding: 0; } .main { background-color: red; } textarea { background-color: gray; resize: none; margin: 0; border: 0 none; padding: 10px; height: 50px; overflow: hidden; } </style> </head> <body> <div class="main"> <textarea><

How can you automatically remove trailing whitespace in vim

可紊 提交于 2019-11-26 14:58:08
问题 I am getting 'trailing whitespace' errors trying to commit some files in git. I want to remove these trailing whitespace characters automatically right before I save python files. Can you configure vim to do this? If so, how? 回答1: I found the answer here. Adding the following to my .vimrc file did the trick. autocmd BufWritePre *.py :%s/\s\+$//e 回答2: Compilation of above plus saving cursor position: fun! <SID>StripTrailingWhitespaces() let l = line(".") let c = col(".") %s/\s\+$//e call

git: change styling (whitespace) without changing ownership/blame?

十年热恋 提交于 2019-11-26 13:05:22
问题 We have a massive, ancient codebase that needs a lot of cleanup. We have always had coding standards and everyone has always tried to follow them, but they were not enforced so over time a lot of violations have creeped in. Many of them are just whitespace issues, like using tabs instead of spaces, or spaces where there shouldn\'t be any, or missing spaces where they should be. We are going to start actively enforcing our coding standards to make sure more violations don\'t creep in, but it\

Efficient way to remove ALL whitespace from String?

二次信任 提交于 2019-11-26 12:00:42
I'm calling a REST API and am receiving an XML response back. It returns a list of a workspace names, and I'm writing a quick IsExistingWorkspace() method. Since all workspaces consist of contiguous characters with no whitespace, I'm assuming the easiest way to find out if a particular workspace is in the list is to remove all whitespace (including newlines) and doing this (XML is the string received from the web request): XML.Contains("<name>" + workspaceName + "</name>"); I know it's case-sensitive, and I'm relying on that. I just need a way to remove all whitespace in a string efficiently.

How to remove leading and trailing white spaces from a given html string?

我只是一个虾纸丫 提交于 2019-11-26 10:25:42
问题 I have the following html string. What would be sample code in JavaScript to remove leading and trailing white spaces from this string? <p>  </p> <div> </div> Trimming using JavaScript<br /> <br /> <br /> <br /> all leading and trailing white spaces <p>  </p> <div> </div> 回答1: See the String method trim() - https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/Trim var myString = ' bunch of <br> string data with<p>trailing</p> and leading space '; myString = myString

How to remove whitespace from right end of NSString?

烈酒焚心 提交于 2019-11-26 09:50:31
问题 This removes white space from both ends of a string: NSString *newString = [oldString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; How do I remove white space from just the right end of a string? UPDATE: The code from the accepted answer is now part of SSToolkit. Yay! 回答1: UPDATE: A quick benchmark showed that Matt's own adaption, based on Max' & mine, performs best. @implementation NSString (TrimmingAdditions) - (NSString *

How to remove leading and trailing whitespace in a MySQL field?

被刻印的时光 ゝ 提交于 2019-11-26 06:58:13
问题 I have a table with two fields (countries and ISO codes): Table1 field1 - e.g. \'Afghanistan\' (without quotes) field2 - e.g. \'AF\'(without quotes) In some rows the second field has whitespace at the start and/or end, which is affecting queries. Table1 field1 - e.g. \'Afghanistan\' (without quotes) field2 - e.g. \' AF\' (without quotes but with that space in front) Is there a way (in SQL) to go through the table and find/replace the whitespace in field2? 回答1: You're looking for TRIM. UPDATE