hi....
How to remove the new line character in the left and right side of the sting value in mysql?
Can you any one give me the sample query for this?
Regards,
S.Ashokkumar
9 32357
Hi folks,
update tab set fld_name=select replace(str,'\n ','') [where clause if there];
Hi folks,
update tab set fld_name=select replace(str,'\n ','') [where clause if there];
hi...
If we use the replace function to replace the new line, it will repalce all the new lines in the string...i dont want to remove the new line between characters. i want to remove from left side and right side of the string only.
Regards,
S.Ashokkumar.
code green 1,726
Recognized Expert Top Contributor
Sorry I can't answer fully but I would think that you need the LEFT and RIGHT string functions along with REPLACE, within a SELECT statement as a subquery of UPDATE
can u post a sample data and ask b'coz i could not understand your question?
hi....
How to remove the new line character in the left and right side of the sting value in mysql?
Can you any one give me the sample query for this?
Regards,
S.Ashokkumar
If u have all the value in that field with newline character at the begining and
the end of the field.
Then u have use this query,
SELECT SUBSTRING(<Fiel dName>,2,LENGTH (<Fieldname>)-2) FROM Table;
Try this... sure this will help you
Thanks,
Pimp.
hi....
How to remove the new line character in the left and right side of the sting value in mysql?
Can you any one give me the sample query for this?
Regards,
S.Ashokkumar
In MySQL this is quite easy:
select trim(both '\n' from FIELDNAME) from TABLE;
So if your table is "stuff" and the field is "descriptio n" you would say:
select trim(both '\n' from description) from stuff;
I'm searching for an easy way to trim all whitespace (spaces, tabs, and newlines) from strings in MySQL. No luck so far. I can stack up trim calls, but this doesn't work when the whitespace contains a mix of different kinds of whitespace, unless I iteratively apply the stacked trim statement until the new result == the previous result (el yuko).
Why "trim" doesn't kill all leading/trailing whitespace rather than only one flavor of it at a time is beyond me. This capability has been a standard part of all significant programming language string libraries for at least 15 years. *sigh*
Another approach is to write a Java program that connects to your database, loads the strings in question, applies String's trim method (which does the RIGHT THING(tm) by removing ALL leading/trailing white space), and writes them back to the DB. More work up front, but reusable.
Hope this helped!
It may not be elegant, but this relatively short option does work for removing all white space.
eg. update table1 set text1 = replace(replace (replace(text1, ' ',''),'\t',''), '\n','');
' A dog jumped
over the moon
and a cat swam the river.'
becomes:
'Adogjumpedover themoonandacats wamtheriver.'
To trim only the leading/following white space and get rid of any embedded formatting characters without losing the space between words, try:
select replace(replace (trim(both ' ' from text1),'\t','') ,'\n',' ') as new_text from test;
' A dog jumped
over the moon
and a cat swam the river.'
becomes:
A dog jumped over the moon and a cat swam the river.
after query, do it by replacing "\n" with empty string in your programming language.
example of using C#: - string a;
-
string b = a.Replace("\n", "");
thank you so much,
grat........wor ked for me
replace(replace (trim(both ' ' from field),'\t','') ,'\n',' '),
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: runningdog |
last post by:
Hi,
I would like to be able to embed a newline in a text string.
Is there any convienent notation to do this
TIA Steve
|
by: Alex Nordhus |
last post by:
I am looking for a way to strip the blank line and the empty newline at
the end of the text file. I can get the blank lines removed from the
file but it always leaves the end line (which is blank) as a newline. My
code is here and it works but leaves the newline at the end of the file.
How do I get rid of it?
import re
f =...
|
by: surendran.d |
last post by:
hi,
I am using gcc 3.4.4 for c++, i am getting the following
warning if there is no new line at the EOF. Why this warning and i am
not getting the warning in vc++ compiler.
thanks,
suri
|
by: Daniel Mark |
last post by:
Hello all:
I have the following snippet:
In : fileName = 'Perfect Setup.txt\n'
In : fileName = fileName # remove the '\n'
character
In : fileName
Out: 'Perfect Setup.txt'
|
by: LEM |
last post by:
Hi,
I'm trying to remove any empty lines from a string, and I am doing the
following:
String pp;
pp = "\r\n\r\n1\r\n23\r\n\r\n4";
pp = pp.Replace("\r\n\r\n", "\r\n");
| |
by: linq936 |
last post by:
Hi,
I read in many places that the string to be outputted by printf()
must be ending with newline, for example, it should be
printf("Hello World.\n");
instead of
printf("Hello World.");
|
by: bgold12 |
last post by:
Will newlines ever be standardized? I recently discovered that in a
textarea, internet explorer adds \r\n for every newline you enter,
while firefox adds \n. I know \r is also used in some places... will
this ever be fixed?
|
by: ofilha |
last post by:
I am trying to export the resultset of a query to a character delimited file. I am using the wizard for this. However, one of the fields is 512 characters long and it accepts from form address. It looks like the field contains newlines, but when i look at the resultset in DB2 i don't see any newline characters, only after i copy it and then...
|
by: alex21 |
last post by:
I am trying to write a function for determining the data type of columns in a delimited file.
However my function is not detecting a newline and exiting the loop after the end of the first line.
* 'del_2' is equal to a new line character, i have tested this using a small bit of code
if del_2 = ControlChars.NewLine then
...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |