Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Basic regular expression

Posted on 2009-07-06
6
Medium Priority
?
151 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 2000 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
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

782 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