andrewkwon / substitute_text_and_repeat

Tool for performing simple text substitution and repetition on a marked up text
0 stars 0 forks source link

Allow for more complex substitution logic #2

Open andrewkwon opened 1 year ago

andrewkwon commented 1 year ago

I think it might be nice if there were ways to do more complex substitutions than the straightforward string substitutions that are currently supported.

For example, I wanted to be able to take an input

This is a document on cats: cats-cats-cats-cats-cats. Aren't cats great? Wow. So cat. So very cat.

And replace each instance of cat with the count of how many times cat has been seen:

This is a document on cats (1): cats (2)-cats (3)-cats (4)-cats (5)-cats (6). Aren't cats (7) great? Wow. So cat (8). So very cat (9).

It might also be nice to be able to replace all strings that match a regular expression. In general, I just think it'd be cool to have more flexibility and power with how substitutions are done.

andrewkwon commented 1 year ago

Although, it could definitely be argued that that would be overcomplicated for this tool. I want to keep it very simple. What is the best possible ratio of power to complexity here?