Macro for Open, Find and Replace and Save
-
@Lycan-Thrope :
I will take your comments into account.
Greetings :-) -
@guy038 said in Macro for Open, Find and Replace and Save:
Hello, @josé-luis-montero-castellanos, @aln-kilborn and all,
@josé-luis-montero-castellanos, regarding your regex S/R :
-
SEARCH
(?s)(<St)(.)(/S)(.)(<Xt)(.)(/X)|(<Xt)(.)(/X)(.)(<St)(.)(/S) -
REPLACE
?1\5\2\7\4\1\6\3:${12}${9}${14}${11}${8}${13}${10}
Why do you need the leading in-line modifier
(?s), in the search part ? Do you mean that the single char.in group2,4,6,9,11and13may also represent a line-break char (\ror\n) ?I suppose not ! Then, your correct search regex is rather :
(?-s)(<St)(.)(/S)(.)(<Xt)(.)(/X)|(<Xt)(.)(/X)(.)(<St)(.)(/S)where any
.single char will represent a non-break char, only !
Now, I noticed that the groups used, in replacement, for each alternative of the search regex, are in the same order ! Then, you can use, preferably, a specific feature of the Boost Regex engine, called
Branch ResetFor instance, in your regex, the numbers of each group are :
(?-s)(<St)(.)(/S)(.)(<Xt)(.)(/X)|(<Xt)(.)(/X)(.)(<St)(.)(/S) Gr : 1 2 3 4 5 6 7 |8 9 10 11 12 13 14If we use the
Branch Resetfeature the search regex becomes :(?-s)(?|(<St)(.)(/S)(.)(<Xt)(.)(/X)|(<Xt)(.)(/X)(.)(<St)(.)(/S)) Gr: 1 2 3 4 5 6 7 |1 2 3 4 5 6 7Thus, your entire regex S/R can be simplified as below :
-
SEARCH
(?-s)(?|(<St)(.)(/S)(.)(<Xt)(.)(/X)|(<Xt)(.)(/X)(.)(<St)(.)(/S)) -
REPLACE
\5\2\7\4\1\6\3
For instance, given this INPUT text :
<St2/S4<Xt6/X <Xt9/XB<StD/SYou would get the OUTPUT text, below :
<Xt2/X4<St6/S <St9/SB<XtD/XNotes :
-
The
Regular expressionoption must be selected -
Preferably, tick the
[Wrap around](https://www.ahijoy.com/)option
Best Regards,
guy038
I tried it but didn’t work
-
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login