Hi,
I have a txt file to read and I'm using this regular expression
Regex rx = new Regex (@"^( <N>\d{3})\s( <DATA>\d\d/\d\d/\d\d)\s+( <TELEFONE>\d+)\s+( <LOCALIDADE>.{15})\s( <UF>\S\S)\s( <INICIO>\d\dH\d\dM\d\d)\s+( <DURACAO>\d+,\d)\s+( <MODALIDADE>\S\S)\s+( <VALOR>\d+,\d\d)", RegexOptions.Multiline);
And it works fine for this data
DATA TELEFONE LOCALIDADE UF INICIO DURACAO MODALIDADE VALOR
008 26/02/06 50920267 S PAULO SP 14H28M42 0,6 4B 0,04
009 09/03/06 35371314 S PAULO SP 09H20M36 1,0 4D 0,31
010 10/03/06 50920660 S PAULO SP 10H54M54 1,8 4D 0,55
011 13/03/06 35371314 S PAULO SP 13H20M12 0,5 4K 0,07
012 14/03/06 35371314 S PAULO SP 17H56M48 0,9 4D 0,27
013 16/03/06 36480148 S PAULO SP 14H45M12 0,5 4D 0,15
014 16/03/06 36480148 S PAULO SP 14H47M00 0,5 4D 0,15
015 17/03/06 30370933 S PAULO SP 12H02M48 1,4 4K 0,21
016 17/03/06 35371314 S PAULO SP 16H22M54 7,0 4D 2,17
017 23/03/06 35371314 S PAULO SP 10H52M48 25,5 4D 7,91
018 25/03/06 55070408 S PAULO SP 17H51M42 0,5 4B 0,03
019 28/03/06 35371314 S PAULO SP 18H42M48 1,8 4K 0,27
But when I get something like
DATA TELEFONE LOCALIDADE UF INICIO DURACAO MODALIDADE VALOR
022 07/03/06 77186047 AREA 011 12H44M24 1,7 1K 1,12
023 14/03/06 78523887 AREA 011 18H41M42 0,9 1K 0,59
024 17/03/06 77259980 AREA 011 19H30M24 4,2 1K 2,78
or
DATA TELEFONE LOCALIDADE OPERAD. INICIO DURACAO MODALIDADE VALOR
029 02/03/06 74345520 AREA 011 VIVO 12H53M06 1,1 4K 0,74
030 02/03/06 74345520 AREA 011 VIVO 15H27M48 0,5 4K 0,33
031 02/03/06 74345520 AREA 011 VIVO 15H50M12 0,7 4K 0,47
032 02/03/06 73888655 AREA 011 VIVO 12H40M48 2,9 1K 1,95
It doesn't work so I tried
Regex rx =
new Regex (@"^( <N>\d{3})\s( <DATA>\d\d/\d\d/\d\d)\s+( <TELEFONE>\d+)\s+( <LOCALIDADE>.{15})\s( <OPERAD.>\S\S)\s( <INICIO>\d\dH\d\dM\d\d)\s+( <DURACAO>\d+,\d)\s+( <MODALIDADE>\S\S)\s+( <VALOR>\d+,\d\d)", RegexOptions.Multiline);And I got group name invalid....
Is there a way to read this three possibilities with one regular expression or I'll have to use three of then
Can you help me to contruct the other two possibilities if needed
thanks
PS: The diference between the 2o and third is the "OPERAD." column that the second doesn't have, and from the second to the first is the "LOCALIDADE" column that have numbers also and the column "UF" is empty
Thanks a lot

Regular Expression with two possibilities ???
Big Bearded Guy
Thanks, that application solves all of my problems !!!!
HEHE
rickywong
It is the dot in the field OPERAD you have changed!
Try with the or ( | ) operator...or try using operator using both uf and modalidade
try "the regulator" software from
http://regex.osherove.com/
regards
ema