Web based family history software

Question regular expression help

  • mariannevanharten
  • Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
3 months 3 weeks ago #1 by mariannevanharten
regular expression help was created by mariannevanharten
In my tree I have many duplicate notes, once restricted and once public.
I want to delete the public one, probably by using a regular expression.

1 FACT 1495
2 TYPE CBG-PKPL
1 FACT 1495
2 RESN CONFIDENTIAL
2 TYPE CBG-PKPL

The value 1495 is different in each record.

I tried to search
1 FACT %1\n2 TYPE CBG-PKPL\n1
replace by an empty field
and using Search mode Regular expression.

What is going wrong?

Best regards,
Marianne

Please Log in or Create an account to join the conversation.

More
3 months 3 weeks ago #2 by Franz Frese
Replied by Franz Frese on topic regular expression help
I can't see a note!

Please Log in or Create an account to join the conversation.

More
3 months 3 weeks ago #3 by drblam
Replied by drblam on topic regular expression help

In my tree I have many duplicate notes, once restricted and once public.
I want to delete the public one, probably by using a regular expression.

1 FACT 1495
2 TYPE CBG-PKPL
1 FACT 1495
2 RESN CONFIDENTIAL
2 TYPE CBG-PKPL

The value 1495 is different in each record.

I tried to search
1 FACT %1\n2 TYPE CBG-PKPL\n1
replace by an empty field
and using Search mode Regular expression.

What is going wrong?

Best regards,
Marianne
Every time someone posts a question about regular expressions I spend far too long trying to figure out which REGEX dialect is required. Can this be posted somewhere easy to find, please??

When you ask "What is going wrong?", do you mean (a) the pattern does not find anything, or (b) the substitution doesn't change anything, or (c) something else? It's hard to help without knowing....

From the top of my head, it seems that the "1" at the very end of the pattern is the start of the next line (presumably the second occurence of 1 FACT ..." that contains the restriction), so the replacement pattern should be "1" rather than an empty field.

Beyond that, I don't know how to interpret "%1" which presumably is supposed to match the rest of the line somehow.  In particular, it doesn't appear in the REGEX "cheat sheet" I found at github:
remram44.github.io/regex-cheatsheet/regex.html

Please Log in or Create an account to join the conversation.

More
3 months 2 weeks ago #4 by fisharebest
Replied by fisharebest on topic regular expression help
> What is going wrong?

%1 matches exactly that - a percent symbol and the digit 1.

To match a the "1495" part (which you say changes), you can use ".+"

The dot matches any character (except newline), and the + means repeated 1 or more times.

If this is always a going to be a number, then you can use [0-9]+ to match a sequence of digits.

Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum