Solved

Basic regular expression

Posted on 2009-07-06
6
141 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
Comment Utility
You can just do a replace

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

Author Comment

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

Expert Comment

by:crisco96
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
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 74

Expert Comment

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

Author Closing Comment

by:andieje
Comment Utility
many thanks
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

772 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

12 Experts available now in Live!

Get 1:1 Help Now