-1

I have two questions - both related to my gedcom-file for my genealogical tree (I use both notepad++ and textpad):

1.)

I have around 1000 people, who have De, La, Le, Van, Von, etc., as part of their Surname (in the beginning of it), and I would like for instance “Von” to be part of their Given Name (in the end of it).

How can I do a change for all the people (as a global change), who is for example named “Von”?

2.)

I have many double village/town/city names, for instances “Copenhagen, Copenhagen, Denmark”. I would the double word just to be a single word, so it would be “Copenhagen, Denmark”.

How can I do a change so double words becomes a single word (as a global change?

Hope someone can help me with these two questions.

Thanks in advance!

Best regards, Nick

Here is an example on what I mean:

0 @I@ INDI 1 NAME Anna /Von Hat/ 2 GIVN Anna 2 SURN Von Hat 1 BIRT 2 DATE 01 Jan 2000 2 PLAC Copenhagen, Copenhagen, Denmark

To:

0 @I@ INDI 1 NAME Anna von /Hat/ 2 GIVN Amalie Nydia Anna von 2 SURN Lysarch Koenigk 1 BIRT 2 DATE 01 Jan 1940 2 PLAC Copenhagen, Denmark

  • Hi Nick! welcome to SO. What regex code did you try so far? and can you give an example of the first question? – Ibrahim Feb 17 '19 at 00:00
  • Hi Ibrahim, Thanks. I tried many combinations, but they did not work at all. Best regards, Nick – Nick MacGregor Sadolin Feb 17 '19 at 00:04
  • Could you add some of your regex combination to the question as well as a real example of your first question? – Ibrahim Feb 17 '19 at 00:09
  • Ibrahim, as I wrote I have tried with several combinations and none of them worked. I have not worked with global changes before so I am all new to this. The example is a real example. Only name and date have been changed (using a non real person). If I knew how to do it, I would not need help. – Nick MacGregor Sadolin Feb 17 '19 at 00:14
  • Even if they didn't work, it is always nice to add some of the codes that you have tried to your question. This shows people that you have made an effort to solve the issue. Hope my answer helps you! – Ibrahim Feb 17 '19 at 00:30
  • I how now managed to fix the second question about the double village/town/city names For instance Copenhagen, Copenhagen, Denmark Was changed to: Copenhagen, Denmark I used "Regular Expression" in Notepad++ I wrote in “Find What”: (\b\w+\b,)\W+\1 I wrote in “Replace With”: (\b\w+)\W+\1 Thereafter I had bw+W+ Copenhagen, Denmark So in "Normal" I searched for: bw+W+ Copenhagen, Denmark And replaced it with: Copenhagen, Denmark And then the issue was fixed. However I have not managed to fix the name issue, and could use help here. – Nick MacGregor Sadolin Feb 17 '19 at 00:42

1 Answers1

2

For the first question, you you can add these names inside a round brackets to create a group for them and add the sign of the optional | between them as the following. (De|La|Le|Van|Von). This code will highlight them all and add them in a group. Then, match the first name based on your text by using whatever cue these first names have. For example:

([a-zA-Z]+) \/(De|La|Le|Van|Von) 

Then replaced by

$1 $2 /

Demo: https://regex101.com/r/9QT99V/2/

As for the second question, you could make use of this sign \1 which matches the repeated instances. For example, in your code, you could match the cities by matching any word that is followed by a comma ,, and make them inside a group by using ( ), then add \1 to match the repeated string. Example:

([a-zA-Z]+, )\1

Replace with:

$1

Demo: https://regex101.com/r/Dm76wn/1/

Ibrahim
  • 6,006
  • 3
  • 39
  • 50