473,765 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Remove Carriage return and line feeds.

8 New Member
Hi.

I have form that has a text box. I want insert unformatted text into the database.
Even if the user gives an carriage return or New line feed in the database it should be stored as on single line without any formatting.

I just want to remove
New Line Feed(\n)
Carriage Return(\r)
spaces at the begin and end of the string.

Eg:
If i have
text1(enter key pressed)
text2(enter key pressed)
text3(enter key pressed)
Blank space
Blank space

I want this to be stored in the DB as:
text1 text2 text3

Could someone help me with this?

Thanks
Apr 7 '08 #1
4 4700
ronverdonk
4,258 Recognized Expert Specialist
For removing characters you can use the str_replace() command.

We can help you when you start writing your own code. Then come back here when you run into problems or have questions. We do not supply ready made code.

Ronald
Apr 7 '08 #2
coolguyraj
8 New Member
I already have the code ,Everything works fine but i want to store the data from a textarea without any formatting into the database.

Currrently it stores data with formatting like (\n)(\r)
i want to strip them off. and use one single line with spaces between words.

i used str_replace() but that does not seem to work.

Can someone helpme with this.

Thanks
Apr 7 '08 #3
aktar
105 New Member
Try str_replace() with ascii codes
Apr 7 '08 #4
ronverdonk
4,258 Recognized Expert Specialist
Show your str_replace command here. I wonder if you defined the \n and \r within single quotes. When you did: that does not work. You have to include them within double quotes.

Show your str_replace() command anyway (within code tags)

Ronald
Apr 7 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
31359
by: | last post by:
Hi, I want to send an Email using ASP (I know how to to this) The body of the Email contains several variabels How do I concat string values and separate them by carriage returns/ Line feeds? Any help will be greatly appreciate. Regards,
4
24771
by: McKirahan | last post by:
How would I use a regular expression to remove all trailing Carriage Returns and Line Feeds (%0D%0A) from a textarea's value? Thanks in advance. Also, are they any great references for learning how to use Regular Expressions?
5
16069
by: McKirahan | last post by:
I'd like to use regular expressions to remove extraneous Carriage Return Line Feeds (CrLf) from a textarea before the form is submitted. I'd like to remove all trailing CrLf's and convert all instances of 3 consectutive CrLf's to just 2. I first escape() the textarea and match "%0D%0A" (i.e. CrLf). Here's what I've been testing; watch for word-wrap:
6
17597
by: Laura D | last post by:
How can I identify a carriage return in C++? \r, \f, \0, \n, \t does not work. I have also tried !isprint(ch), iscntrl(ch), isspace(ch), etc....with no luck! I even poked around in the MSDN and found some code that MS claims will save a file in unix format and I cut and pasted into my program(and made changes to suit): ..... char ch; char temp="\0"; //Open the file for reading in binarymode. ifstream fp_read(filename.c_str(),...
2
3257
by: Lila Godel | last post by:
I am having a problem with the download of web pages via the WebClient.DownloadFile function in the specialized VB.Net 2003 I.E. plug-in I am designing to speed up the work on my latest project. When I edit the web pages in notepad I see a square wherever I normally see a carriage return and a line feed when viewing the source in I.E. How can I make the web pages come down readable so I can easily make my two manual deletions...
2
6519
by: James | last post by:
below is some codes. my arraylist below reads from a file. My files contains blank line (ie carriage return) My message dialog shows all strings being captured. However i do not want my array to contain "blank" string/line/carriage return How do i remove the index so that my arraylist become smaller ?
0
1050
by: ajfish | last post by:
Hi, I've noticed that if a return value from a web service is a string, any carriage return/line feed pairs in that string get converted to plain line feeds. For all I know, this happens on incoming parameters as well, though I haven't tested it. surely this is a serious flaw in the implementation. the very least we should be able to assume from a transport service is that the data gets there uncorrupted
0
1823
by: J.Marsch | last post by:
I am having a problem in which ASP.Net web services are corrupting my data. I know that my problem is related to the standard way of encoding carriage return linefeeds, so I need to figure out how to correctly encode them. I am trying to return XML strings that were generated by calling DataTable.WriteXml() from my web service, and then using DataTable.ReadXml to deserialize the data. The problem is that some of the data in the...
5
13368
by: vflyer | last post by:
I there a quick routine that removes trailing newline chars and carriage return? vFlyer Labs http://www.vflyerlabs.com
0
9568
marktang
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9398
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10160
Oralloy
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9832
tracyyun
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8831
agi2029
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6649
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2805
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.