Fine, you are now searching, thinking and trying before asking. So I will help you a little.
First your macro contains 1
EndIf too much.
Second you can speed up your macro if you delete all strings between [lang_en]...[/lang_en] which are single line strings by using a single regular expression replace all (in UltraEdit style).
Find RegExp "^[lang_en^]*^[/lang_en^]"
Replace All ""
This regex will delete occurrences like:
[lang_en]
normal single line string[/lang_en]
[lang_en]
single line string with [ inside[/lang_en]
You can also remove all strings between [lang_en]...[/lang_en] even if they are spanned over multiple lines with a single regular expression, but only if there is no [ character within the string.
Find RegExp "^[lang_en^][~^[]+^[/lang_en^]"
Replace All ""
This regex will delete occurrences like:
[lang_en]
line 1 of a multi-line string
line 2 of a multi-line string
line 3 of a multi-line string[/lang_en]
But to make sure that really every string between [lang_en]...[/lang_en] is deleted, finally the loop must be used to also delete strings like:
[lang_en]
line 1 of a multi-line string
line 2 of a multi-line string with a [ character inside
because of a nested other [tag]...[/tag] block[/lang_en]
The whole macro with the enabled macro property
Continue if a Find with Replace not found looks like as follows:
InsertMode
ColumnModeOff
HexOff
UnixReOff
Top
Find RegExp "^[lang_en^]*^[/lang_en^]"
Replace All ""
Find RegExp "^[lang_en^][~^[]+^[/lang_en^]"
Replace All ""
Loop
Find "[lang_en]"
IfNotFound
ExitLoop
EndIf
StartSelect
Find Select "[/lang_en]"
IfFound
EndSelect
Delete
Else
EndSelect
ExitLoop
EndIf
EndLoop
Top
Add UnixReOn or PerlReOn (v12+ of UE) at the end of the macro if you do not use UltraEdit style regular expressions by default - see search configuration. Macro command UnixReOff sets the regular expression option to UltraEdit style.
I have described the
Find Select method at:
How to select everything between two predefined strings in different lines?
Special note:
I have written once that
IfFound is not possible after a
Find Select "" command. This is not true anymore. IDM seems to have fixed this bug. I don't know at which version. For this example it is important to use
IfFound instead of
IfSel because the first searched string
[lang_en] is still selected even if the second searched string is not found. If you have a version of UltraEdit where the
IfFound does not work after Find Select "", you can first unselect the first search string and move the cursor to the start of the first search string. For this example the loop with a possible workaround would look like:
Loop
Find "[lang_en]"
IfNotFound
ExitLoop
EndIf
EndSelect
Key LEFT ARROW
Find Up "["
EndSelect
Key LEFT ARROW
StartSelect
Find Select "[/lang_en]"
IfSel
EndSelect
Delete
Else
EndSelect
ExitLoop
EndIf
EndLoop
A second solution for the UNSELECT AND MOVE BACK code is:
EndSelect
Key LEFT ARROW
Key Ctrl+LEFT ARROW
Key LEFT ARROW
Key Ctrl+LEFT ARROW
Key LEFT ARROW