serges_newj
serges_newj

Reputation: 815

Use count of repeating occurrences for replace

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

Answers (1)

Cyrbil
Cyrbil

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

enter image description here

To install the plugin:

  • Go to Plugins > Plugin Manager > Show Plugin Manager
  • Select TextFX Characters and then click Install.

Upvotes: 1

Related Questions