public void PreenchendoListaArtigos() { bool SaoArtigos = false; int CountArtigos = 0; StringBuilder sb = new StringBuilder(); var PalavrasDaJuris = InteiroTeor.Split(' '); var PreviousWord = PalavrasDaJuris.ElementAt(0); foreach (var CurrentWord in PalavrasDaJuris) { if (SaoArtigos) { if (CurrentWord.EndsWith(".") || CurrentWord.Equals(".") || CurrentWord.EndsWith(")") || CurrentWord.Equals(")") || CurrentWord.EndsWith(":") || CurrentWord.Equals(":") || CurrentWord.EndsWith(@"\") || CurrentWord.Equals(@"\") || CurrentWord.EndsWith("\"") || CurrentWord.Equals("\"") || CurrentWord.EndsWith("\n") || CurrentWord.EndsWith("\r") || CountArtigos > 8) //Precisa de um maximo, de ler 8 palavras após achar um "ARTIGOS" { sb.Append(CurrentWord); SaoArtigos = false; CountArtigos = 0; sb.Clear(); } else { sb.Append(CurrentWord); CountArtigos++; } } else { if (PreviousWord.Contains("ARTIGOS") && Util.PalavraContemDigito(CurrentWord)) //Se a palavra anterior é "ARTIGOS" e a atual contem numeros { SaoArtigos = true; sb.Append(CurrentWord); } else if (PreviousWord.Contains("ART.") || PreviousWord.Equals("ARTIGO") || (PreviousWord.Equals("ART"))) { if (Util.PalavraContemDigito(CurrentWord)) //Só adicionará a lista de artigos caso a palavra posterior contenha um numero (Ex: Art. 23) { ListaArtigos.Add(CurrentWord); } } else if (CurrentWord.StartsWith("ARTS.") || CurrentWord.StartsWith("ART.") || CurrentWord.StartsWith("art.") || CurrentWord.StartsWith("arts.")) { if (Util.PalavraContemDigito(CurrentWord)) //Só adicionará a lista de artigos caso a palavra posterior contenha um numero (Ex: Art. 23) { ListaArtigos.Add(CurrentWord); } } } PreviousWord = CurrentWord.ToUpper(); } NormalizaArtigos(); }