Estou tentado obter dois valores específicos em cada linha de um arquivo txt. Conforme o exemplo:
15/06/2016 R$ 638,69 R$ 2.562,46
15/07/2016 R$ 672,43 R$ 2.533,51
15/08/2016 R$ 658,93 R$ 2.504,75
15/09/2016 R$ 1.362,28 R$ 2.471,80
15/10/2016 R$ 1.342,20 R$ 2.435,41
15/11/2016 R$ 1.321,80 R$ 2.398,40
Preciso obter de cada linha os dois valores ex: "R$ 638,69" e "R$ 2.562,46", mas como os valores podem alterar de centavos a milhões. Não tem como eu ler a string por posição! Tentei montar um regex
mas sem sucesso. Alguém com uma ideia melhor?
if (FileUpload1.HasFile)
{
using (StreamReader texto = new StreamReader(FileUpload1.FileContent))
{
while ((mensagem = texto.ReadLine()) != null)
{
mensagemLinha.Add(mensagem);
}
}
for (int i = 0; i < mensagemLinha.Count; i++)
{
string re1 = "()";
string re2 = ".*?";
string re3 = "(\\$)";
string re4 = "( )";
string re5 = ".*?";
string re6 = "(,)";
string re7 = ".*?";
string re8 = "(R)";
string re9 = "(\\$)";
string re10 = "( )";
string re11 = ".*?";
string re12 = "(\\.)";
string re13 = ".*?";
string re14 = "(,)";
Regex rex = new Regex(re1 + re2 + re3 + re4 + re5 +
re6 + re7 + re8 + re9 + re10 + re11 + re12 +
re13 + re14, RegexOptions.IgnoreCase | RegexOptions.Singleline);
Match valores = rex.Match((mensagemLinha[i].ToString()));
lblArq.Text += valores ;
}