# Regular expression in filters - RegExp $1 to $9 properties

**URL:** <https://gramps.discourse.group/t/regular-expression-in-filters-regexp-1-to-9-properties/746>\
**Category:** Help\
**Tags:** regular-expression\
**Created:** [September 18, 2020, 4:48pm UTC](https://gramps.discourse.group/t/regular-expression-in-filters-regexp-1-to-9-properties/746 "2020-09-18T16:48:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![PLegoux](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/plegoux/32/413_2.png) [@PLegoux](https://gramps.discourse.group/u/PLegoux)\
**Post date:** [September 18, 2020, 4:48pm UTC](https://gramps.discourse.group/t/regular-expression-in-filters-regexp-1-to-9-properties/746/1 "2020-09-18T16:48:34Z")

</div>

Hi,

To see if I’ve described [who is on my photos](https://gramps.discourse.group/t/how-to-store-a-text-with-citations-and-media/724/44), I have created an attribute “Recognized persons” associated to each media with people on it and I have assigned it a value like number\_recognized/total\_persons\_number.

What I want to do is to search for the unrecognized people on pictures so I have created an attribute filter:

Attribute: Recognized persons  
Value: `(\d{1,n})/($1)`  
Regexp: Checked

I reverse the filter to get only media with a Number of Recognized People different of total Number of People on the Picture.

But, it seems that `(\d{1,n})/($1)` don’t work - nor `(\d{1,n})/$1`.

Does this kind of regexp with `$n` properties implemented in Gramps?

---

<div class="post-metadata">

**Author:** ![DaveSch](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/davesch/32/40_2.png) [@DaveSch](https://gramps.discourse.group/u/DaveSch)\
**Post date:** [September 18, 2020, 6:55pm UTC](https://gramps.discourse.group/t/regular-expression-in-filters-regexp-1-to-9-properties/746/2 "2020-09-18T18:55:04Z")

</div>

I am no expert on [Regular Expressions](https://gramps-project.org/wiki/index.php?title=Gramps_5.1_Wiki_Manual_-_Filters#Regular_Expressions) but the link is what Gramps has on their use.

PS: can you edit the discussion header to better describe this Discussion is about “Regular Expressions in Filters” . My first thought was that you were selling something.

---

<div class="post-metadata">

**Author:** ![DaveSch](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/davesch/32/40_2.png) [@DaveSch](https://gramps.discourse.group/u/DaveSch)\
**Post date:** [September 18, 2020, 7:24pm UTC](https://gramps.discourse.group/t/regular-expression-in-filters-regexp-1-to-9-properties/746/3 "2020-09-18T19:24:20Z")

</div>

> [@DaveSch](#):
>
> PS: can you edit the discussion header to better describe this Discussion is about “Regular Expressions in Filters” . My first thought was that you were selling something.

👏 👏 👏 👏 👏 👏 👏 👏 👏 👏

---

<div class="post-metadata">

**Author:** ![PLegoux](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/plegoux/32/413_2.png) [@PLegoux](https://gramps.discourse.group/u/PLegoux)\
**Post date:** [September 19, 2020, 10:53am UTC](https://gramps.discourse.group/t/regular-expression-in-filters-regexp-1-to-9-properties/746/4 "2020-09-19T10:53:09Z")

</div>

I’ve [found](https://docs.python.org/2.7/howto/regex.html#non-capturing-and-named-groups) this working regular expression:

```python
(?P\<reco>\d+)\/(?P=reco)

```

It seems expression I’d used before is a Java RegExp, Python RegExp works better.

Note that links in Regular Expressions wiki page Dave cited points to their wikipedia definition and the regexp web site. Usefull but not so usefull than to say we can use any python regexp defined into python manual. May be something to add to the manual.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/gramps/original/1X/2ac1e712b7adf612e31ca08a55419f4cf37c0158.png) [@system](https://gramps.discourse.group/u/system)\
**Post date:** [October 19, 2020, 10:53am UTC](https://gramps.discourse.group/t/regular-expression-in-filters-regexp-1-to-9-properties/746/5 "2020-10-19T10:53:10Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
