How to get lettercount for each word in field

B

bsgoldbg

I have a field containing a description of a product and I want to
identify all descriptions containing words greater than x characters
long so that I can break them up into smaller chunks (for formatting
purposes). How can I run a query that will give me the descriptions
containing words with greater than x (say 15) characters? I thought
about doing a length on the whole description field and dividing the
number of spaces to get an average letter count, but that would be
exremely unreliable.

Any thoughts?

TIA

Brian
 
R

Rick Brandt

bsgoldbg said:
I have a field containing a description of a product and I want to
identify all descriptions containing words greater than x characters
long so that I can break them up into smaller chunks (for formatting
purposes). How can I run a query that will give me the descriptions
containing words with greater than x (say 15) characters? I thought
about doing a length on the whole description field and dividing the
number of spaces to get an average letter count, but that would be
exremely unreliable.

Any thoughts?

There is no built in function that will do this. You would need a user-defined
VBA function to do it and on a large table this could be pretty slow.

The function would take the field value as a parameter and then use the Split
function to build an array of all words. The array would then be looped through
measuring the length of each word and storing that length in a variable if it is
greater then the existing value of the variable. At the end of the loop you
would have the number of characters of the longest word in the field and that
would be the valued returned by the function.

Your query would use that function and filter out all rows where the value from
the function is 15 or less.
 
J

John Nurick

Hi Brian,

An expression like this (watch out for wrapping) should find fields that
contain a sequence of 15 or more characters with no space:

WHERE [Description] LIKE '*[! ][! ][! ][! ][! ][! ][! ][! ][! ][! ][!
][! ][! ][! ][! ]*'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top