Re: Stripping out unwanted characters
- From: "vinu" <vinu.t.1976@xxxxxxxxxxxxxx>
- Date: Wed, 22 Feb 2006 13:32:41 -0000
HI,
Use regular expression to remove unwanted characters and then send the
string to database. Here is a sample code to remove non-alphanumerical
characters from a string.
hoep this will help you...
public static void Main()
{
/*Reg expression to find non-alphanumeric characters*/
string pattern = @"[^A-Za-z0-9]";
/*include System.Text.RegularExpressions name space*/
Regex rgx = new Regex(pattern);
string inputStr = "ab$!Cd&%$gf£!";
/*Replace non-alphanumeric characters with space*/
string outputStr = rgx.Replace(inputStr, " ");
Console.WriteLine("Output string:"+ outputStr);
}
Cheers
Vinu
"et" <eagletender2001@xxxxxxxxx> wrote in message
news:ODVkXK7NGHA.668@xxxxxxxxxxxxxxxxxxxxxxx
How can I strip out unwanted characters in a string before updating the
database? For instance, in names & addresses in our client table, we want
only letters and numbers, no punctuation. Is there a way to do this?
.
- References:
- Stripping out unwanted characters
- From: et
- Stripping out unwanted characters
- Prev by Date: RE: error when moving a vs 2005 precompiled site to test server
- Next by Date: Re: Stripping out unwanted characters
- Previous by thread: Stripping out unwanted characters
- Next by thread: Re: Stripping out unwanted characters
- Index(es):
Relevant Pages
|
|