String Manipulation: Add function regexCount or support for regEx in count funcitons

Hi @mwiegand,

Having recently heard about the new “Expression” node that is currently in development, which among other (future) things will be a more modern replacement for String Manipulation and Math Formula, it sounds like now would be an ideal time for us all to put together our wish lists of such functions to help push the direction on that!

Always up for a String Manipulation challenge though… the best I’ve come up with on a “regex count” is this:

length(
	regexReplace(
		regexReplace($column1$,"A[0][0-9]{2}" ,"¬" )
	,"[^¬]",""))

So given a pattern to find e.g. A[0][0-9]{2}, this will replace all occurrences of that pattern with a character I’m not expecting to find in the string “¬” and then use regex to replace every character in the resulting string that is not “¬” with "", and then return the length of the result, which should (if my theory is correct) be the count of occurrences of that regex pattern.

Presented with the string A090B100A2030A560A0ABB90A012A456
The count of occurrences A[0][0-9]{2} (i.e. A followed by 0 followed by 2 digits) is: 2

I’ll admit the function doesn’t exactly roll off the keyboard though :wink:

1 Like