Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

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