ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests Early 2026. Make sure to check your account preferences in my.alteryx.com to make sure you have filled out your security questions. Learn more here
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Count a specific characters in a string

Cpirino
8 - Asteroid

Hi,

 

Is possible to count a specific characters in a string?

Exemple:

I have a path "C:\Users\cpirino\Desktop\Alocação\Arquivos alocados\SEMANA 32\20180806_08_34_24.txt" and I need the number of "\" in this path.

 

 

Att.

1 REPLY 1
Claje
14 - Magnetar

Hi,


There's two ways to do this.  One uses Regex, one does not.

 

The Regex solution:

REGEX_CountMatches([Yourfield],'\\')

We include two "\" characters to escape the \ in REGEX.  If I test this formula we get a total of 7 matches.

 

Non-REGEX

LENGTH([Yourfield])-LENGTH(REPLACE([Yoourfield],"\",""))

This option basically involves taking the original length of the field, and subtracting the length of the field if we delete all "\" characters.  This also finds 7 matches.

 

Both of these will work, which you use is up to you.

Labels
Top Solution Authors