Page 1 of 1
Find all occurrences
Posted: Mon Jun 04, 2018 5:07 am
by gcotterl
Is there way to find the number of times "are" occurs in this list:
are are thi
thi are are
are are are
are thi are
thi thi thi
thi thi are
are are thi
The result should be 12
Posted: Mon Jun 04, 2018 8:03 am
by ben_josephs
Search | Replace... (
<F8>):
Find what: \bare\b
Replace with: are
[X] Regular expression
Replace All
The number of replacements is displyed in the status bar.
You can undo the replacement to keep your editing history in good order.
Posted: Mon Jun 04, 2018 2:10 pm
by gcotterl
Thanks!
Posted: Wed Jun 20, 2018 7:49 pm
by gcotterl
Is there way to find the number of times "goat" occurs in this list:
goat goat thi
thi goat goat
goat goat goat
goat thi goat
thi thi thi
thi thi goat
goat goat thi
The result should be 12
Posted: Wed Jun 20, 2018 7:53 pm
by ben_josephs
Didn't I already answer that?
Posted: Wed Jun 20, 2018 8:03 pm
by gcotterl
Yes.
It worked when the string is 'are' but not when the string is 'goat'
(The error says: "Invalid back reference: specified capturing group does not exist. The error occurred while parsing the regular expression:
'\g>>>HERE>>>oat\b'
Posted: Wed Jun 20, 2018 9:11 pm
by ben_josephs
Not
\goat\b
but
\bgoat\b
\b matches a word boundary. It stops are maching in, for example, claret.
Posted: Wed Jun 20, 2018 9:37 pm
by gcotterl
Thank you
Posted: Fri Jun 29, 2018 11:40 am
by AmigoJack
Alternatively use the "Mark all" button, which will also print in the status bar how often it matched.
Posted: Fri Jun 29, 2018 12:34 pm
by ben_josephs
No it doesn't. It shows how many lines were marked, not how many matches were found, despite its indicating otherwise.
Posted: Mon Jul 02, 2018 2:21 pm
by AmigoJack
You are right, didn't know this. Looking into the manual (speak: help file) however it's already explained as "marks every line" instead of every "occurance". This should be fixed (status bar should also use the word "line") and enhanced (another button called "count matches").