Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
Check out our powerful new search update! You can read more here. Please let us know if you have any feedback by creating a topic here.
SOLVED

Count a specific characters in a string

Highlighted
Meteoroid

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.

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