Length of words in a string.

M

MN

Hello all -

I'm really at wits end on this as I'm not having much success with locating
a function or other options I have. I'm working on a message board for a
website and I'm needing to check the length of the words that users put in.
For example, when someone puts in "yesssssssssssss!", I put together a small
function that omits all of the s's as this is wreaking havoc on the layout of
tables within the site. But I don't have a solution if someone types in
"ssss ssasdfjskldjfaskld;jfaskdf" as random ambiguous letters. I know I can
check the length of the entire string but don't know to check the words
within it.

Any help at this point is appreciated.

Thanks,
MN
 
T

Tim Slattery

MN said:
Hello all -

I'm really at wits end on this as I'm not having much success with locating
a function or other options I have. I'm working on a message board for a
website and I'm needing to check the length of the words that users put in.
For example, when someone puts in "yesssssssssssss!", I put together a small
function that omits all of the s's as this is wreaking havoc on the layout of
tables within the site. But I don't have a solution if someone types in
"ssss ssasdfjskldjfaskld;jfaskdf" as random ambiguous letters. I know I can
check the length of the entire string but don't know to check the words
within it.

What constitutes a word? Are they delimited by blanks? In that case
there are two in your string, one short and one quite long. Maybe by
spaces and semicolons. Now there are three strings, two short and one
rather long.

There's no way to be really certain as to what combination of letters
constitutes a word, other than a dictionary (and then you omit
something from the dictionary that one of your users *knows* is a
word.)
 
M

MN

Thanks for responding Tim. To answer your questions, what constitues a word
for what I'm planning on would be a blank(s) between the words. Also, I was
considering setting a limit where if a "word" is encountered of more than 50
characters, I'd notify the user to rephrase. I'm sure there are words that
possibly could exist of that length but I would just notify the person to
re-phrase, rather than restrict them (i.e. just putting a space between your
50 character word so it's 2 25's) or something like that.

Thanks.
 
H

Hal Rosser

MN said:
Hello all -

I'm really at wits end on this as I'm not having much success with locating
a function or other options I have. I'm working on a message board for a
website and I'm needing to check the length of the words that users put in.
For example, when someone puts in "yesssssssssssss!", I put together a small
function that omits all of the s's as this is wreaking havoc on the layout of
tables within the site. But I don't have a solution if someone types in
"ssss ssasdfjskldjfaskld;jfaskdf" as random ambiguous letters. I know I can
check the length of the entire string but don't know to check the words
within it.

Any help at this point is appreciated.

Thanks,
MN

Look at the "split" function to separate a string into an array of strings
(words)
then you can check the length of the words, one by one - if thats what you
want to do.
look at "instr" function to see if one string is in another
look at the "mid" function to return parts of a string
look at the replace function to modify parts of a string
the "len" function returns the length of the string
left(stringname, 5) returns the first 5 characrters of stringname
and on and on
Check out this website
http://devguru.com/technologies/vbscript/13896.asp

It also has a decent reference for ASP and ADO and Javascript
 
G

Giles

MN said:
Thanks for responding Tim. To answer your questions, what constitues a
word
for what I'm planning on would be a blank(s) between the words. Also, I
was
considering setting a limit where if a "word" is encountered of more than
50
characters, I'd notify the user to rephrase. I'm sure there are words
that
possibly could exist of that length but I would just notify the person to
re-phrase, rather than restrict them (i.e. just putting a space between
your
50 character word so it's 2 25's) or something like that.

Thanks.

Assuming your window size can vary as the user resizes their browser, once
you have found the words that are too long to fit your smallest window size
(as suggested by Hal, with split), you can break them to allow wrapping by
inserting a space with a tiny font size
Yessssss<span style="font-size:1pt"> </span>ssssss
This clunk will be invisible in wide windows, and allow wrapping when
needed.
If you have a problem with the actual script needed to do this, let the
group know.
Giles
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top