Suppose a writer wants to keep an eye on their fondness for the semicolon. They want an agent that collects notes with (say) more than two semicolons in the text.
How would you approach this? (I know one way, but it’s a little bit ugly. I bet there’s a better approach.).
I can’t find that anywhere and it is not picked up by syntax colouring. But, this works:
$MyNumber=$Text.replace("[^;]","").size();
In case you are wondering, this pattern does pick up all semi-colons even if occurring as beginning or end characters of the source string. So string ";this;that;" would return a value of 3 for the above code ( i.e. the number of characters in string ";;;").
Note: do not be tempted to use .count() as that is counting the list size of the source string. This is slightly different from list.count() and list.size(), both of which count the number of list items.