ASP String

Discussion in 'ASP General' started by hkhellhkhell@hotmail.com, Sep 30, 2006.

  1. Guest

    i have an application that will take user input from a text box and
    write it
    to an access database. i need to make sure that if they ever enter a
    single
    line of text that it has at least 1 space for every 40 characters.

    so before i write the info to the database i have to make sure there is
    no
    lines of text that are longer than 40 characters without a space, and
    if
    there are insert a space at the 41st character. is that as hard as it
    sounds?

    thank you!!
    from Daniel ()
     
    , Sep 30, 2006
    #1
    1. Advertising

  2. Evertjan. Guest

    wrote on 30 Sep 2006 in microsoft.public.inetserver.asp.general:

    > i have an application that will take user input from a text box and
    > write it
    > to an access database. i need to make sure that if they ever enter a
    > single
    > line of text that it has at least 1 space for every 40 characters.
    >
    > so before i write the info to the database i have to make sure there
    > is no
    > lines of text that are longer than 40 characters without a space, and
    > if
    > there are insert a space at the 41st character. is that as hard as it
    > sounds?


    using asp serverside jscript:

    function anyWordLongerThan40(t){
    return /\S{41,}/.test(t)
    }

    The function when defined in asp jscript, can also be used in asp
    vbscript.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Sep 30, 2006
    #2
    1. Advertising

  3. Evertjan. wrote:
    > function anyWordLongerThan40(t){
    > return /\S{41,}/.test(t)
    > }


    FWIW, there is no need for the open-ended range when using /RegExp/.tesp().
    It suffices to test for 41 consecutive characters:

    return /\S{41}/test(t)




    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms.
     
    Dave Anderson, Oct 2, 2006
    #3
  4. Evertjan. Guest

    Dave Anderson wrote on 02 Oct 2006 in
    microsoft.public.inetserver.asp.general:

    > Evertjan. wrote:
    >> function anyWordLongerThan40(t){
    >> return /\S{41,}/.test(t)
    >> }

    >
    > FWIW, there is no need for the open-ended range when using
    > /RegExp/.tesp(). It suffices to test for 41 consecutive characters:
    >
    > return /\S{41}/test(t)


    Yes,
    one character saved,
    and quite some cpu cycles,
    I love this, Dave,
    it remembers me of the good old assembler days.

    However,
    I would not skip a period:

    return /\S{41}/.test(t)


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Oct 2, 2006
    #4
  5. Evertjan. wrote:
    > Yes,
    > one character saved,
    > and quite some cpu cycles,
    > I love this, Dave,
    > it remembers me of the good old assembler days.


    I wasn't really thinking about it in terms of efficiency. I was making a
    "necessary and sufficient" observation.



    > However,
    > I would not skip a period:


    Right on (laughs at self).



    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms.
     
    Dave Anderson, Oct 2, 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. Mladen Adamovic
    Replies:
    0
    Views:
    745
    Mladen Adamovic
    Dec 4, 2003
  2. Mladen Adamovic
    Replies:
    3
    Views:
    14,645
    Mladen Adamovic
    Dec 5, 2003
  3. Matt
    Replies:
    3
    Views:
    522
    Tor Iver Wilhelmsen
    Sep 17, 2004
  4. Bruce Sam
    Replies:
    15
    Views:
    7,947
    John C. Bollinger
    Nov 19, 2004
  5. =?Utf-8?B?UmFqZXNoIHNvbmk=?=

    'System.String[]' from its string representation 'String[] Array'

    =?Utf-8?B?UmFqZXNoIHNvbmk=?=, May 4, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    1,805
    =?Utf-8?B?UmFqZXNoIHNvbmk=?=
    May 4, 2006
Loading...

Share This Page