simple regex question?

J

Jerry

I am reading lines from a file that I need to breakdown.



while( ( read = FI.ReadLine() ) != null )
{
Console.WriteLine( read );



if( read.Contains( "<var>" ) )
{
Regex r = new Regex( @"^\<(\w+)>(\w+),(\d+),(\d+),(\d+)" );
string[] s = r.Split( read );



}
}
FI.Close();

The above works fine for "<var>StmtBal,7,60,19</var>".

But not for "<var>Acct#,5,0,1</var>" or
"<var>.........Description..........,30,16,6</var>".



How do I handle the "#", "*" etc and ".."?



Thanks,



Jerry
 
P

pigeonrandle

Hi,
Could the "....description....." have a ',' in it? If so, you would
have to work backwards through the string? Other than that, you need to
know which extra symbols you will have.

HTH,
James.
 
L

Lee

Probably replacing
(\w+),
with
([^,]+),
should work. It will match every non-, between the first > and the
first ,.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top