* help with Search and Replace

For users to report plugin bugs and request plugin enhancements; and for authors to test new/new versions of plugins, and to discuss plugin development (in the Programming Technicalities sub-forum). If you want advice on choosing or using a plugin, please ask in General Usage or an appropriate sub-forum.
Post Reply
avatar
rob p
Gold
Posts: 29
Joined: 01 Feb 2021 22:03
Family Historian: V7

help with Search and Replace

Post by rob p » 28 Feb 2021 04:15

I’m not sure if this belongs in the General or Plugin subs…

All of my Generic Sources have a trailing semi-colon at the end of the “Publisher Info” value string. (These were all imported from FTM; this appears to be an artifact of the FTM export.) This semi-colon “messes up” my formatted Footnotes, and I want to delete it. The Search and Replace plugin can uniquely explore this one field (so cool!), but I can’t figure out how to select this “last character” for replacement.

I tried ;\r and some other end-of-line and carriage-return expressions, and combinations of “Show White Space” but can’t select these.

I could do this to the GEDCOM in Notepad++, but “;\r” also picks other cases that I don’t want to modify, and I’d have to verify replacement one-by-one. I have hundreds.

I don’t speak “Lua” (yet). What is the expression or function or “pattern” that will let me do this with the plugin? (Re. the “LUA Pattern Mode” tick-box)
I’ve searched the KB’s -The Lua documentation may be easy to search, but it's hard for me to understand (so far; I’m just starting.).

- rob

User avatar
tatewise
Megastar
Posts: 27088
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: help with Search and Replace

Post by tatewise » 28 Feb 2021 10:58

Yes, you are almost there.

Firstly, assuming that there are no other semicolons you could just Search for ; and Replace with nothing.

But it is safer to use Lua Pattern Mode.
The reason \r or \n etc, won't work is that those characters are not present in the field.
They literally mean \ and r or n and to enter end-of-line you must use the Enter/Newline key.
The FHUG Knowledge Base Understanding Lua Patterns gives a better explanation than the Lua Ref Guide.

In this case, it is the Anchor magic characters that you need.
$ anchors the pattern to the end of the text.
So the Search pattern is ;$
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Mark1834
Megastar
Posts: 2147
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: help with Search and Replace

Post by Mark1834 » 28 Feb 2021 11:11

To complete the explanation, carriage returns are present in the GEDCOM file, as that is plain text, but are not present in the raw data because the Publisher Info field is defined as a single line of text, so cannot contain line end or carriage return characters.

This is a perfect example of where it is appropriate to use the more sophisticated searching capability of the plugin.
Mark Draper

avatar
rob p
Gold
Posts: 29
Joined: 01 Feb 2021 22:03
Family Historian: V7

Re: help with Search and Replace

Post by rob p » 01 Mar 2021 16:07

Thank you, thank you!
"sophisticated capability" indeed.

Post Reply