• KATE regular expression "Replace All"s don't work properly

    From Gary Dale@21:1/5 to All on Mon May 2 02:00:01 2022
    I have a table copied from a  Word document and pasted into KATE that
    I'm trying to convert into an XML file. The table is simple - some tabs,
    a position title, some more tabs, the incumbent's name then the EOL.

    My regex to grab the information is:

            ^\s*([^\t]*)\s*(.*)$

    When I Find All, it reports 33 matches - the number of lines in the table.

    My code to replace it is

    \t\<position\>\n\t\t\<name\>\1\<\/name\>\n\t\t\<incumbent\>\2\<\/incumbent\>\n\t\<\/position\>

    When I do a "Replace", it finds the next match and replaces it. However,
    when I do a "Replace All", it replaces some then stops. In a slightly
    changed version of the replace code (with a \n at the end to leave a
    space between the <position>s), it would replace the first line then add
    a second <position> element with nothing substituted - stopping after
    reporting 8 replacements on the first 4 lines of the table.

    It looks like the regex replacement can't keep track of where it is when
    doing a "Replace All".

    This problem seems to be getting worse lately - earlier in the year
    (with a different, more complicated, replacement) I noticed that I would
    have to keep hitting "Replace All" to get it to finish. The difference
    could be that this time the find code is general enough that it finds
    lines that have already been replaced.

    For example, with a find code of

            \<\/name\>\n

    in this table, to add another element after it, I replace with

            \<\/name\>\n\t\t\<level\>2\<\/level\>\n

    but it stops after 27 replacements. I have to do 6 "Replace"s to get it
    to finish.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)