* Search and Replace Plugin - Anomaly

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
quarlton
Famous
Posts: 166
Joined: 26 Feb 2004 13:07
Family Historian: V7
Location: Lincolnshire
Contact:

Search and Replace Plugin - Anomaly

Post by quarlton »

FH v6.2.7
Windows v10 19041.450
Search and Replace v3.0


I’ve found what appears to be an anomaly.

It would appear that it doesn't like repeating the same Search and Replace action.

Am I missing something?


I’m trying to tidy up a friend’s Addresses & Places entries.
The aim is to remove duplicate spaces and standardise on St, Street, Rd, Road etc.

My first step was to remove the duplicate spaces.

Step 1 Search ONLY for double spaces
Result: 364

Step 2 Search and Replace double spaces with single space
Result: 327 [37 not changed]

Step 3 Save

Step 4 Search and Replace double spaces with single space
Result: 53
The New Value matches the Old Value i.e. no change

Step 5 Repeat Step 4
Result: 53
The New Value matches the Old Value i.e. no change

Step 6 Repeat Step 4 but use ~ as the Replace value
Result: 53
New Values now have ~ instead of double space

With a fresh copy of the data

Step 7 As Step 2 but using ~ as replace value
Result: 327

Step 8 Save

Step 9 Repeat Step 7
Result: 52
The New Value matches the Old Value i.e. no change

Step 10 Repeat Step 4 but use § as the Replace value
Result: 52
New Values now have § instead of double space
Dave Simpson ~ Boulton, Braham, Carney, Simpson and Jacobs
User avatar
tatewise
Megastar
Posts: 28414
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Search and Replace Plugin - Anomaly

Post by tatewise »

Bear with me Dave as there is more to this than meets the eye.

Most importantly, take great care if adjusting Place names as the FH Place records pose a major issue.
See plugins:help:search_and_replace:usage_examples#place_name_changes_in_fh_v6|> Place Name Changes in FH V6 for full details.
If you have already fallen into that trap then use File > Backup/Restore > Revert to Snapshot to undo the problems.

To explain why it needs two passes to replace all double spaces with a single space consider the following.
If there are three spaces then the first pass replaces the first two spaces with one space, leaving two spaces.
So the second pass replaces those two remaining spaces with one space.
It would be easier to use LUA Pattern Mode and set the Search to one space and a plus sign, which matches any number of multiple spaces, so the replacement is completed in one pass.

You say the New Value matches the Old Value but the very fact they appear in the Result Set confirms there was a change.
If there really were no matching data item replacements then a popup message says so and the Plugin does not close.
I suspect it is simply that it is difficult to distinguish one space from two spaces in some fonts.
That is why the Hide/Show White Space options exist in the Plugin, so that in the Current/Replacement Value dialogues it is very clear what white space characters have been affected, in much the same way as in word-processors.

Your Step 9 is confusing, as it is replacing double space with ~ and reports 52 replacements but you claim no change.
But there really should be no changes as after replacing double space with ~ there can't be any double spaces remaining.
I wonder if you are closing the Plugin and seeing the Result Set from the previous pass?
Make sure you close the Result Set between passes to be sure about what you are looking at.
( I intend to change Plugins so they replace the Result Set with a 'nothing changed' Result Set as necessary. )
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
avatar
quarlton
Famous
Posts: 166
Joined: 26 Feb 2004 13:07
Family Historian: V7
Location: Lincolnshire
Contact:

Re: Search and Replace Plugin - Anomaly

Post by quarlton »

Hi Mike

Thanks for the reply.
I've read the Place Name Changes guidance and it doesn't appear to be giving me issues in this particular case.

I always work on a copy when doing search and replace until I'm happy that it's doing what I want - been caught out before :D

Your suggestion of using the LUA Pattern Mode is a good suggestion and I'll give it a try tomorrow - certainly beats multiple iterations to deal with odd numbers of spaces.

I have Show White Space switched on - pity it doesn't affect the results display.

Yes, it's possible that I am seeing previous pass results.

As usual, many thanks for your help.
Dave Simpson ~ Boulton, Braham, Carney, Simpson and Jacobs
User avatar
tatewise
Megastar
Posts: 28414
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Search and Replace Plugin - Anomaly

Post by tatewise »

Dave, try the attached Search and Replace plugin Version 3.0.1 Date 25 Aug 2020.

It now honours the Hide/Show White Space setting in the Result Set.

Also, if it reports No matching data items then it resets the Result Set to say the same.
Last edited by tatewise on 20 Aug 2021 09:58, edited 1 time in total.
Reason: Attachment deleted as later version is in the Plugin Store.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
avatar
quarlton
Famous
Posts: 166
Joined: 26 Feb 2004 13:07
Family Historian: V7
Location: Lincolnshire
Contact:

Re: Search and Replace Plugin - Anomaly

Post by quarlton »

Hi Mike

That is excellent, thank you very much.

It does look as though I was seeing previous results before.
The showing of white space in the results was just what I needed.

Many thanks
Dave Simpson ~ Boulton, Braham, Carney, Simpson and Jacobs
Post Reply