Reputation: 815
I need to find all repeating occurrences of some words in a text and replace each by count of occurrences.
E.g. for text
"Test1: ok ok ok ok ok fail fail ok"
I wish to get
"Test1: ok(5) fail(2) ok(1)"
I could write a simple prog, but maybe is there a simple way to do it by regex?
Upvotes: 0
Views: 214
Reputation: 6478
Regex can not do what you want since it cannot count occurrences. But with the plugin TextFX
, you can have access to many string operations.
The one that should be interesting for you is word count
To install the plugin:
Plugins > Plugin Manager > Show Plugin Manager
TextFX Characters
and then click Install.Upvotes: 1