trim

Is it good practice to trim whitespace (leading and trailing) when selecting/inserting/updating table field data?

Presuming that the spaces are not important in a field's data, is it good practice to trim off the spaces when inserting, updating or selecting data from the table ? I imagine different databases implement handling of spaces differently, so to avoid that headache, I'm thinking I should disallow leading and trailing spaces in any field d...

How to trim whitespace (including tabs)?

I've come to the conclusion that python has a function for just about everything I could ask for. It's just a matter of actually finding these functions. Is there a function that will trim not only spaces for whitespace, but also tabs? Thanks :) ...

Is it possible to Trim recorded audio file in iPhone application?

Hi, My iphone application is recording audio and save it also, but now I want to trim the audio (like iPhone core application 'Voice Memo') after saving, is it possible? or how can i do this thing? Thank you. ...

SQL - Why is parameter trimmed

I have a table (t) with a column (c) defined as varchar 20, containing the values 'a', 'b' and 'c' If I execute the following sql, a value is returned: select * from table where c = 'a ' Why? I assume it's casting/trimming the parameter in some way, but why? How would I really search for 'a ' ...

Trim trailing spaces in XCode

Is there a way to force XCode to trim trailing whitespaces when I save file? I'm using version 3.1.3 if that matters. ...

String from byte array doesn't get trimmed in C#?

Hello :) I have a byte array similar to this (16 bytes): 71 77 65 72 74 79 00 00 00 00 00 00 00 00 00 00 I use this to convert it to a string and trim the ending spaces: ASCIIEncoding.ASCII.GetString(data).Trim(); I get the string fine, however it still has all the ending spaces. So I get something like "qwerty.........." (where d...

assign "it" in each iteration (groovy)

Hey, i try to trim each string item of an list in groovy list.each() { it = it.trim(); } But this only works within the closure, in the list the strings are still " foo", "bar " and " groovy ". How can i achieve that? ...

left trim white space xslt 1.0

I am creating a left trim template and I have this below template: <xsl:template name="str:left-trim"> <xsl:param name="string" select="''"/> <xsl:variable name="tmp" select="substring($string, 1, 1)"/> <xsl:if test="$tmp = ' '"> <xsl:variable name="tmp2" select="substring-after($string, $tmp)"/> <xsl:choose...

How to remove new line characters from data rows in mysql?

I can loop through all of the rows in a php script and do UPDATE mytable SET title = "'.trim($row['title']).'" where id = "'.$row['id'].'"; and trim can remove \n But I was just wondering if something same could be done in one query? update mytable SET title = TRIM(title, '\n') where 1=1 will it work? I can then just execute this...

Trim the ' (apostrophe) character in an sql statement

I'm using the DBMS_SQL package that returns the value '12345' as a value for a column name. How do you trim the apostrophes out from the value so that it could be converted into a number? ...

Left Trim in Javascript

Hey guys, there are lots of scripts out there to trim a string in javascript, but none how to Left Trim String. This is what I use to trim: String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,""); } But I would like to change this a little and create a new function called leftTrim that only removes the leading s...

Trimming string variables by reference in PHP5

I saw another post suggesting using this statement to trim string variables contained in the array: $_POST=array_map('trim', $_POST); However, if in the first place, the strings are not contained in an array, I would like to have a trim function that can be used like this: $a=' aaa '; $b=' bbb '; $c=' ccc '; trimAll($a,$b,$c); //a...

How do you configure JBoss to trim additonal whitespaces generated by JSPs?

Getting lots of additional whitespace in the html output, looks like its because of the JSP tags =/ I saw this referenced somewhere: <init-param> <param-name>trimSpaces</param-name> <param-value>true</param-value> </init-param> That should put it in web.xml, I tried that but that didn't seem to work. Maybe I'm not putting it in t...

Trim file extension UITableView

I want to trim the file extension from text I have NSMutableArray'd in table cells. NSMutableArray *theFiles; NSFileManager *manager = [NSFileManager defaultManager]; NSArray *fileList = [manager directoryContentsAtPath:@"/Test"]; for (NSString *s in fileList){ theFiles = fileList; } cell.textLabel.text = [theFiles obje...

Data clean-up; what layer?

I have an app built on Model-Glue: Unity that contains some search forms. I need to trim leading and trailing spaces from search strings before using them to query the database. I'm also keeping the search terms in a bean that a user can save and re-use. My problem is that I am unsure where to perform that trim(). The bean seems to be t...

The Best Way of Trimming Spaces in a String

How do I trim spaces inside leaving only one space taking consideration of performance? Input: AA BB Output: AA BB Input: A A Output: A A ...

Model binding and display trimmed string property

My strongly typed View inherits from a "Person" object that is created with Linq to SQL. In my "Edit" View, i have to display of course old values: <%= Html.TextBox("FirstName") %> "FirstName" is NCHAR, so it need to be trimmed. So i ended up with: <%= Html.TextBox("FirstName", Model.FirstName.Trim()) %> and this works. But when fo...

Trim trailing space from table contents

I have a table in a SQL server 2000 database with a nvarchar(30) field "details". There are some 10,000 records in that with a trailing space. I need a query to trim the particular field content in all rows. How can I achieve this? Thanks. ...

Leading space with INSERT in MySql

I am doing search results page with PHP & MySql.When you go to the state page, it should call up DISTINCTly every city in which I have a record. It won't list any city for the cities column if they have a leading whitespace. I trim the variable before INSERTing into the database. $prcity = trim($_SESSION['prcity']); Yet I still have ...

Remove trailing empty space in a field content

I am using SQL server MSDE 2000. I have a field called notes of type nvarchar(65). The content is 'Something ' with an extra space after the content (quotes for clarity) in all the records. I used the following command. UPDATE TABLE1 SET notes = RTRIM(LTRIM(notes)) But it does not work. Is there any alternate way to do it? ...