I’m looking to implement a word count algorithm. However, anything that appears within ~two tildes~ is regarded as 1 word. For this reason I think regex is probably the best way to go?
The count must be calculated on every keypress on sample sets of about 10000 characters so it’s good to get it right.
Not tested, but pretty straight forward…
Also, note that
~hi one~two~three four~will count ashi one, two, three four, as well as~hi one~two~three four, even though there isn’t a closing tilde.