Skip to main content
Nintex Community Menu Bar

How to count characters on a string

  • August 3, 2015
  • 2 replies
  • 297 views

Forum|alt.badge.img+16

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"

 

 

 

2 replies

Forum|alt.badge.img+4
  • 37 replies
  • March 28, 2019

@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?


Forum|alt.badge.img+3
  • Rookie
  • 18 replies
  • March 2, 2020

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.