need a help

Discussion in 'C#' started by dineshsachdeva, Aug 22, 2007.

  1. dineshsachdeva

    dineshsachdeva New Member

    Joined:
    Aug 22, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    hi!
    i'm new to the C#. net and need a help for my application, thanks in advance,problem is i have an application which has to read the data which is like this

    -------------------------(white spaces which is in the file)

    --------- abc ---------- d----------- efd----------- de

    xxx----- 25.80---------12.10--------180000.0--------11111

    yyyyyyyy---------------709.-----------.03-------------------

    zz-------------------------------------1426.-------------------------

    and has to make an entry in the database in a table as
    table structure is name, abc , d, efd, de

    first entry should be

    name: xxx
    abc:25.80
    d:12.10
    efd:180000.0
    de:11111

    second entry should be

    name: yyyyyyyy
    abc:
    d:709.
    efd:.03
    de:

    second entry should be

    name: zz
    abc:
    d:
    efd:.1426.
    de:
     
  2. Statement

    Statement New Member

    Joined:
    Mar 12, 2008
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    You would use Regular Expressions to do that very easily for you.

    In .NET, they are located in System.Text.RegularExpressions. Take some time to learn both regular expressions and the framework classes.

    Hint: Use verbatim string literals when building the expressions. Verbatim string literals are like "regular" string literals, except it doesn't include escape characters.

    string regex = "\\s*[a-zA-Z]+\\s*";
    is the same as...
    string regex = @"\s*[a-zA-Z]+\s*";

    Note the @ before the quotes. It becomes a bit more readable when you don't have to worry about escape characters.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice