vesta-webtrees-2-custom-modules / vesta_classic_laf

Vesta Classic Look & Feel (Webtrees 2 Custom Module)
https://cissee.de/
GNU General Public License v3.0
17 stars 2 forks source link

Name Badges - Simplified regex #145

Closed TheDutchJewel closed 5 months ago

TheDutchJewel commented 5 months ago

The regex for the birth name badges uses this regex: /\n1 BIRT(?!\n1)(.(?!\n1))*\n2 SOUR/sm

Why not simplify it like this: /\n1 BIRT((?:\n[2-9] .*?)+)SOUR/sm

Same for other facts.

As far as I can see, the simplified version gives the right results in fewer steps (tested on https://regex101.com/).

ric2016 commented 5 months ago

Your regex matches non-tag SOUR, e.g.

1 BIRT
2 NOTE SOURCE missing!

as well.

TheDutchJewel commented 5 months ago

You are right. This one does work well: /\n1 BIRT.*?(\n2 SOUR|((?:\n[2-9] .*?)+?)\n2 SOUR)/sm

No less complex, but works in fewer steps.