Skip to main content

Sometimes it's needed to count some characters on a string on a Nintex Workflow

 

This sample shows how to calculate it with 3 actions.

 

The used actions are:

 

 

I set a variable named myString with the value 123-1234-12345

 

 

105153_pastedImage_0.png

 

 

Then I create the following variables

 

 

 

105154_pastedImage_1.png

 

 

 

Firstly I count the total characters on my string using the action named "Convert Value"

 

 

105155_pastedImage_2.png

 

Then I count the characters deleting the character you want to count ("-" (hyphen) in this case) , from the string

105156_pastedImage_3.png

 

 

 

Then I use the action named "Math operation"

105157_pastedImage_4.png

 

 

 

So you get the result on the variable named "myResult"

 

 

 

@fhunth does this show the character count 'live'? as the person is typing, or only once the form has been submitted?

I have a use for showing the number of characters typed into a cell / control whilst the person is typing it in, is that possible with this solution?


Another way to do this, for any string, with two actions:





  1. Regular expression action.



    • Pattern = the string you're counting in the pattern (escaping any special characters with a backslash).


    • Operation = Extract.


    • Input Text = text variable you're searching.


    • Store result in collection variable.






  2. Collection operation action.



    • Target collection = collection variable from first action.


    • Count.


    • Store result in: number variable.







Reply