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:
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.