Hi,
The code found the first regular expression and the replace works well, but in the array "matches" change the position
and the next iteration doesn't look for ##FECHAINFRACCION## if not "AINFRACCION## .Le c".
I use the same method in a document with format doc and works well, but with a document with format html not.
string templateHTML = "<p><strong><<<<<<<<<<< CAMBIAR TEXTO >>>>>>>>>>>>>>>>>>>>>>>>>>>>></strong></p><p><strong>Aprecio Seguros Info:</strong> En relación con la multa del vehiculo ##MATRICULA## con fecha de infracción ##FECHAINFRACCION## .Le confirmamos que hemos abierto el expediente Nº ##EXPEDIENTE## Mas info <strong>902123147</strong></p>";
Document document = new Document();
using (TextReader sr = new StringReader(templateHTML))
{
document.LoadHTML(sr, Spire.Doc.Documents.XHTMLValidationType.None);
}
Regex re = new Regex(@"\##\w+\##");
TextSelection[] matches = document.FindAllPattern(re);
foreach (TextSelection text in matches)
{
document.Replace(text.SelectedText, "New Text");
}
resultOuput = document.GetText();
Thanks!