original : http://www.blogjava.net/pts/archive/2013/06/10/400 ... Date : 2013-06-10
Transferred from: http://www.ityuedu.com/article/26601034478/;jsessionid=546A853CF3B219B9A242C75E039CB846
Recently used rails to make a small little website, the database is sqlite3, the database data is imported from an XML file, there are many leading carriage return and the end of the empty line, and the page will automatically replace the return of the display, the result is the content of the display of the end of the many more blank, The entire page looks very non-crab coordinated. Today, I decided to get rid of these useless carriage returns and break the line.
Not just a trim, soon into the SQLite command line interface, enter:
sqlite> Update jokes set Content=trim (content, ' \ n ');
Get it done.????? Refresh the page A look, I have a go, no Yes ~, SQLite do not recognize \ n, change to trim (content, ' \ R '), Trim (content, ' \ r \ n ') and trim (content, ' \n\r ') are not, brother is a lazy person, do not want to write code to solve, So Google, found someone to provide this solution:
x ' hh ' should work, where HH is hex digits. So if your file contained hex 0D type line breaks:update t SET essay_without_newlines = Replace (essay, X ' 0D ', ' ~ ');
In other words, SQLite can use the syntax of X ' HH ' to represent a character. Try the next X ' 0D ', no ... try x ' 0A 'again, just fine:
sqlite> Update jokes set Content=trim (content, X ' 0A ');
Journal a pen, there is no technical content. It is purely a memo, and I hope to be helpful to others.
Http://liang.eu/web-dev/trim-newlines-in-sqlite3
"Go" removes the front and rear carriage return newline (newline) in the Sqlite3 database