Solved

Basic regular expression

Posted on 2009-07-06
6
142 Views
Last Modified: 2013-11-07
Hi

I need help removing some characters from an input string. When the input string is stored in sql server 2005 the characters appear as squares. What characters are these? I thought perhaps they were line breaks as there are 2 of these characters at the end of each line of text (by that i mean the 2 characters together encode a line break). Whatever they are i would like to remove them from my input and I don't know what regular expression i need to match them

many thanks
0
Comment
Question by:andieje
  • 2
  • 2
  • 2
6 Comments
 
LVL 15

Accepted Solution

by:
crisco96 earned 500 total points
ID: 24786054
You can just do a replace

StringVariable.Replace("\n", "").Replace("\r", "")
0
 

Author Comment

by:andieje
ID: 24786455
thanks for yoru reply
why are you doing that in 2 separate replace calls?
0
 
LVL 15

Expert Comment

by:crisco96
ID: 24786872
I think I've heard somewhere that the way linux and windows handles carriage returns is different, like I think windows used \n\r, where linux just does \n, so just to be safe I replaced both separately with an empty string.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 24787365
You might want to copy the text into a text editor to verify that the boxes do indeed represent line breaks (most likely they are, but if they're not, you might as well know in advance).

Also,

    *nix: LF (\n)
    Windows: CR (\r) + LF (\n)
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 24787371
For the last post, the order is as posted for Win.:  \r\n
0
 

Author Closing Comment

by:andieje
ID: 31600197
many thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now