How to extract character from alphanumeric strings in ASP.NET

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • davidson1
    New Member
    • Feb 2008
    • 144

    How to extract character from alphanumeric strings in ASP.NET

    Hai,

    i have a string 04AF045 in that AF are character , others are numbers ,
    now what i need is i have to extract AF alone in ASP.NET written in vb.

    if anybody know pl reply me..

    other example

    05AD100

    i have to extract AD alone . if U know the coding , how to store in strings and extract pl reply me soon...Urgent.. .

    Posted Date:- 8 Feb 2008

    Davidson
  • Shashi Sadasivan
    Recognized Expert Top Contributor
    • Aug 2007
    • 1435

    #2
    [CODE=cpp]Regex regex = new Regex("[^a-zA-Z]");
    Console.WriteLi ne("Enter string: ");
    string input = Console.ReadLin e();
    input = regex.Replace(i nput, "");
    Console.WriteLi ne("Formatter text : \'{0}\'", input);[/CODE]

    If you do not want to use regular expressions, you would have to iterate through each character in the string and attach it to the end of another string if it meets your criteria

    Comment

    Working...