Words Count

Hi All,

Trying to find a function that will return a count of total word strings in a field. Is this possible?

There is no readymade function for this (I wonder what the application would be).
You could do something like remove any alphanumeric character (like letters and numbers) and then measure the length of the string as the leftovers should represent the separators.
You may have to treat the result if there is punctuation and blanks in the string as these count individually.

You could try this


Yes it is possible.
At first please tell us how do you define a 'word'?
Which characters are allowed to delimit a word?

For example ... how many words are in the following string?
Mozart P Con #7 In F For 2/3 Pianos, K 242, "Lodron" - 3. Rondeau


Apologies if my original post was vague. In the artist field I wanted to flip FIRSTNAME LASTNAME to LASTNAME, FIRST NAME and also FIRSTNAME MIDDLENAME LASTNAME to LASTNAME, FIRSTNAME MIDDLENAME. The word count function request was to filter the artist field to 2 or 3 word strings in order to try to simply this process, and to run it in larger batches.

In the artist and albumartist fields there tends to be less of a punctuation issue. I'll try your suggestions and work more on a solution. If I have success I will be sure to share.

I wouldn't do that.
Even with the information about the number of words you will create absolutely senseless transformations like

Floyd, Pink
Zeppelin, Led
Pink, Kissing the
Hollywood, Frankie goes to
Or what about artist entries that feature several artists:
Katrina and the Waves
Dave Dee, Dozy, Beaky, Mick and Titch
or the "Friday Night in San Francisco" album by "Al Di Meola, John McLaughlin, Paco De Lucia" (!)

In the end you will never know where to look: for the last name or for the name just the way it is spelled.

Just to give you an idea:
$cutRight($regexp(%ARTIST%', ','(.?) (\w), ','$2, $1; '),2)
Pearl Jam, Neil Young
Jam, Pearl; Young, Neil

Read there ...
Regular Expressions
Regular Expressions
Multiple value artist tag to multiple value artistsort
Need help with regex for ARTISTSORT
Automating Changes to Artist Values

Filter for counting "words", which are separated by one or more space characters:

"$if(%ARTIST%,$add($len($regexp($regexp(%ARTIST%,' +',' '),'[^ ]',)),1),0)" GREATER 1

... will display all artists with more than one word.

"$if(%ARTIST%,$add($len($regexp($regexp(%ARTIST%,' +',' '),'[^ ]',)),1),0)" IS 3

... will display all artists with three words.