ASP String

H

hkhellhkhell

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 ([email protected])
 
E

Evertjan.

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

Dave Anderson

Evertjan. said:
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)
 
E

Evertjan.

Dave Anderson wrote on 02 Oct 2006 in
microsoft.public.inetserver.asp.general:
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)
 
D

Dave Anderson

Evertjan. said:
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).
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top