none
Regex replace text working only for few words (Problem please help) RRS feed

  • Question

  • I have for example this words in documents

    firma_o, num_o, tel_o, etc..., firma_p, num_p, etc...  when I use Regex 

    Regex regexText = new Regex("firma_o");
    docText = regexText.Replace(docText, "Firma asd");
    regexText = new Regex("ulica_o");
    docText = regexText.Replace(docText, "xxx");
    Regex regexText_Cislo = new Regex("cislo_o");
    docText = regexText_Cislo.Replace(docText, "xxx");
    regexText = new Regex("psc_o");
    docText = regexText.Replace(docText, "xxx");
    regexText = new Regex("mesto_o");
    docText = regexText.Replace(docText, "xxx");

    it rename only firma_o, when I rename firma and all other in to firmao, ulicao etc.. then it rename nothing.

    I use vs 2015, Open XML SDK 2.5

    How to rename text as I want in this example?
    Monday, July 23, 2018 3:09 PM

Answers

  • Ok, I found solution, problem was I partialy rewrite text in Word, for example I have word Firma and I replace F in to f and add "_" and save document. Regex didn't find firma_ and others. If I select whole word Firma or firma_ and rewrite it completly then Regex found text and replace it.
    • Marked as answer by Striebrovlas Monday, July 23, 2018 3:56 PM
    Monday, July 23, 2018 3:56 PM