Length of words in a string.

Discussion in 'ASP General' started by MN, Jan 27, 2006.

  1. MN

    MN Guest

    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
    MN, Jan 27, 2006
    #1
    1. Advertising

  2. MN

    Tim Slattery Guest

    "MN" <> wrote:

    >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.)

    --
    Tim Slattery
    MS MVP(DTS)
    Tim Slattery, Jan 27, 2006
    #2
    1. Advertising

  3. MN

    MN Guest

    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.

    "Tim Slattery" wrote:

    > "MN" <> wrote:
    >
    > >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.)
    >
    > --
    > Tim Slattery
    > MS MVP(DTS)
    >
    >
    MN, Jan 27, 2006
    #3
  4. MN

    Hal Rosser Guest

    "MN" <> wrote in message
    news:...
    > 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
    Hal Rosser, Jan 28, 2006
    #4
  5. MN

    Giles Guest

    "MN" <> wrote
    > 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
    Giles, Jan 29, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sam
    Replies:
    3
    Views:
    14,096
    Karl Seguin
    Feb 17, 2005
  2. Peter Strøiman
    Replies:
    1
    Views:
    2,086
    Peter Strøiman
    Aug 23, 2005
  3. Replies:
    5
    Views:
    664
    John W. Kennedy
    Jan 11, 2007
  4. BerlinBrown
    Replies:
    6
    Views:
    4,483
  5. pantagruel
    Replies:
    8
    Views:
    444
    Dr John Stockton
    Jul 22, 2006
Loading...

Share This Page