If a text field has > 30 '#' then show alert
Ninox Profile

Wondering if there's a formula that will check a text field for the number of hashtags (#) and if there's more than 30, allow to pop up an alert or have field become visible alerting to the fact?

Ninox Profile

I also need a way to count the number of characters in a text field (the min/max text length wont work for what I need)

Ninox Profile

Hi,

Try this for the first question in a formula field: you can always add if r>30 then alert("message") end 

let r := 0;
let k := length(Text);
for i from 0 to k do
if substring(Text, i, i + 1) = "#" then
r := r + 1
end
end;
r

As you can see the answer on your second question is length(string)

Steven

Ninox Profile

@Steven, I hope you don't mind me submitting an alternative solution. I saw this post last night, but was too tired to respond.

 

length(replacex(Text, "[^#]", "g", ""))

 

When I first started learning Regex, I thought my brain was going to explode! I found it very non-intuitive, but it's very powerful. The solution I posted is really a workaround because the extractx() function does not work the way it should in my opinion.

 

@Frank Böhmer, I sent an email to support for an explanation of the usage of the extractx() function and the response was unhelpful to say the least. I can forward that email exchange if you like. One point I would like to make is it is inconsistent to change the order of function parameters...

 

extractx(string, regular_expression, flags, extract)

extractx(string, regular_expression, extract)

 

Per your documentation "extract" is the 4th parameter if "flags" is used and the 3rd parameter if "flags" isn't? Doesn't make much sense. In addition, the "flags" argument doesn't appear to work at all in the extractx() function. What is the "extract" argument?? I did find that "extract" does relate to groups, but does it represent anything else?? The extractx() function appears to mimic the match() function in Javascript so the following script should return an array of "#" if the extractx() intends to match Javascript's match() or a string matching the result of the replacex() script above.

 

length(extractx(Text, "#", "g"))

Ninox Profile

Sean,

No problem at all, I'm not familiar with RegEx (I know you do, an I was already kinda expecting an answer from you 😁 ) so I gave an alternative solution.

Steven.

Ninox Profile

Steven, 😎

Reply