View Single Post
Old 01-25-2023, 01:02 PM   #6
enuddleyarbl
Guru
enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.
 
enuddleyarbl's Avatar
 
Posts: 791
Karma: 1538394
Join Date: Sep 2013
Device: Kobo Sage
Quote:
Originally Posted by Turtle91 View Post
At a quick glance (I haven’t tested and am responding from my phone) I would say you need to provide a capture for the id= portion as well if you want to just MOVE it. So the search/replace would look something like this:

Code:
SEARCH: (\w)(<[^/].+?></.+?>)(\w)|(\w)(<[^/].+?/>)(\w)
REPLACE: \2\1\3 -or- \1\3\2
I'll respond with the crux of my above edit. Yep. I had to grab the tag stuff (the id= stuff). Plus, I had to get the whole word fragments before and after the tags (in order to move the tags after the whole word).
Code:
SEARCH: (\b\w+?)(<[^/]+?></.?>)(\w+?\b)
REPLACE: \1\3\2
Unfortunately, I still can't figure out how to handle replacement groups with an OR ("|") in the midst of the search string. So, I stuck with the non-self-terminating-tag option.

EDIT: To the best of my knowledge, the above search should set the first replacement group as starting from the nearest word boundary and running to the starting "<" of the interrupting tags.
The second group should be everything from there that's in a <blah></somethingelse> pair.
The third group should start from there and run to the next word boundary.
The replacement of \1\3\2 sticks the first and last bits of the word together and then appends the tag set afterward.

EDIT 2: I had a spurious plus ("+") in the search string for the closing tag. That made it look for at least one character after the "/" and if it didn't find one inside the tag, it happily continued looking until if either found one somewhere else or ran out of paragraph. I think I've fixed it (again). Sorry.

Last edited by enuddleyarbl; 01-25-2023 at 04:58 PM.
enuddleyarbl is offline   Reply With Quote