Hello
Anyone know REGEX code that allow us count number of notes for each reference and filter records by number chosen?
For example:
Show me references that have five or (more/less) notes, or between 10 and 20 notes, for instance.
Thanks
How to count number of notes with REGEX?
Re: How to count number of notes with REGEX?
I am far from an SQL/REGEX expert, but I can make a small contribution that might get you started.
This will find any reference with non-newline characters in the notes field (this is entered in the SQL search box):
notes REGEX '.'
To find notes with more than one note (as determined by there being two returns in a row -- it doesn't test to see if there is actually text after the two returns), use this
notes REGEX '.' AND notes REGEX '\n\n'
As for specifying the number of instances of 2 returns in a row, I know it can be done but not how to do it.
Jon
Sonny Software
This will find any reference with non-newline characters in the notes field (this is entered in the SQL search box):
notes REGEX '.'
To find notes with more than one note (as determined by there being two returns in a row -- it doesn't test to see if there is actually text after the two returns), use this
notes REGEX '.' AND notes REGEX '\n\n'
As for specifying the number of instances of 2 returns in a row, I know it can be done but not how to do it.
Jon
Sonny Software
Re: How to count number of notes with REGEX?
I've done a little better. This search seems to find a references with entries in the notes field with a minimum number of two return separators between them. In the example below, Bookends would find notes with 4 or more notecards. At least that's how it's working for me.
notes REGEX '.' AND notes REGEX '[\n\n.*]{3}'
Perhaps someone else can offer a better solution.
Jon
Sonny Software
notes REGEX '.' AND notes REGEX '[\n\n.*]{3}'
Perhaps someone else can offer a better solution.
Jon
Sonny Software
Re: How to count number of notes with REGEX?
For me don't work.
I get references with 1, 2 or more notes
I'm curious with one thing.
Why notes are in the same table that references and not in other related table?
I'm sure that you have good reasons for this.
Thank you.
I get references with 1, 2 or more notes

I'm curious with one thing.
Why notes are in the same table that references and not in other related table?
I'm sure that you have good reasons for this.
Thank you.
Re: How to count number of notes with REGEX?
You can search the Internet for Regex tips (which is what I did) and see if you can come up with a better solution.
Notes in the same table because they belong to that particular reference, there never was any intention for no sharing of notes between references.
Jon
Sonny Software
Notes in the same table because they belong to that particular reference, there never was any intention for no sharing of notes between references.
Jon
Sonny Software
Re: How to count number of notes with REGEX?
I've tested this in Refs -> SQL/Regex Search and it works
notes regex '.' AND notes regex '[\n\n.*]{2,}'
It counts the number of times the pattern 2 returns followed by text occurs in the notes field and returns true if the there a specified number or more. In the example, above Bookends will find the reference if there are 2 or more occurrences of the pattern. Note that this means Bookends will find references with 3 notecards or more (the first notecard is not preceded by returns).
If it doesn't work for you I have no explanation.
Jon
Sonny Software
notes regex '.' AND notes regex '[\n\n.*]{2,}'
It counts the number of times the pattern 2 returns followed by text occurs in the notes field and returns true if the there a specified number or more. In the example, above Bookends will find the reference if there are 2 or more occurrences of the pattern. Note that this means Bookends will find references with 3 notecards or more (the first notecard is not preceded by returns).
If it doesn't work for you I have no explanation.
Jon
Sonny Software
Re: How to count number of notes with REGEX?
I'm sorry if I seem a heavy, but...
https://www.dropbox.com/s/04q6nx0oh1fqo ... 1.mp4?dl=0
https://www.dropbox.com/s/04q6nx0oh1fqo ... 1.mp4?dl=0
Re: How to count number of notes with REGEX?
I think I know what is the problem.
Those notes which has inside asterisk "Moi importante*****" is considered as valid and is considered like various notes (as much notes as asterisks has the note)
For instance:
#@1 high intensity aerobic activity, children, VO2max
>The aim of this study was to investigate the effect of high intensity aerobic activity in five weeks, two sessions per week, on children’s VO2peak. Additionally we wanted to test whether ten-year old boys were able to sustain intensity over 80 % of reart ratepeak (HRpeak) for a relative long period of time (up to 4 minutes), using aerobic games and play.
IMPORTANTE*****
Is only one note, but regex expressión consider that are six notes (the note + one note for each asterisk).
Those notes which has inside asterisk "Moi importante*****" is considered as valid and is considered like various notes (as much notes as asterisks has the note)
For instance:
#@1 high intensity aerobic activity, children, VO2max
>The aim of this study was to investigate the effect of high intensity aerobic activity in five weeks, two sessions per week, on children’s VO2peak. Additionally we wanted to test whether ten-year old boys were able to sustain intensity over 80 % of reart ratepeak (HRpeak) for a relative long period of time (up to 4 minutes), using aerobic games and play.
IMPORTANTE*****
Is only one note, but regex expressión consider that are six notes (the note + one note for each asterisk).
Re: How to count number of notes with REGEX?
In fact, the problem happen when any note has regex metacharacters at the end of any line (before carriage return)
Re: How to count number of notes with REGEX?
Then try removing the .* from the search.
notes regex '.' AND notes regex '[\n\n]{2,}'
You're going to have to do some research and experimenting, too. This is a power user feature and definitely not my area.
Jon
Sonny Software
notes regex '.' AND notes regex '[\n\n]{2,}'
You're going to have to do some research and experimenting, too. This is a power user feature and definitely not my area.
Jon
Sonny Software
Re: How to count number of notes with REGEX?
Ok.
I'm working on it, but, at the moment...
If anybody else has any idea about it...welcome!!!
Thank you, Jon.
I'm working on it, but, at the moment...
If anybody else has any idea about it...welcome!!!
Thank you, Jon.