-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVisualizador.cs
48 lines (39 loc) · 1.61 KB
/
Visualizador.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Text.RegularExpressions;
namespace EditorHTML
{
public static class Visualizador
{
public static void Mostrar(string texto)
{
Console.Clear();
Console.WriteLine("Modo Visualização");
// Linha de separação
for (var i = 0; i <= 40; i++)
Console.Write("-");
SubstituirCaracteres(texto);
Console.ReadKey();
Menu.Mostrar();
}
public static void SubstituirCaracteres(string texto)
{
// Expressão regular para encontrar o conteúdo dentro de <strong>...</strong>
var strongRegex = new Regex(@"<strong>(.*?)<\/strong>", RegexOptions.IgnoreCase);
// Percorre o texto e imprime palavra por palavra
int lastIndex = 0;
foreach (Match match in strongRegex.Matches(texto))
{
// Exibir a parte do texto antes da tag <strong>
Console.Write(texto.Substring(lastIndex, match.Index - lastIndex));
// Exibir a palavra dentro da tag <strong> com destaque
Console.ForegroundColor = ConsoleColor.Yellow; // Cor para destacar
Console.Write(match.Groups[1].Value);
Console.ResetColor(); // Restaura a cor original
// Atualiza a posição do índice
lastIndex = match.Index + match.Length;
}
// Exibir qualquer parte restante do texto
Console.WriteLine(texto.Substring(lastIndex));
}
}
}