472,145 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

ASP String

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 (da*********@hotmail.com)

Sep 30 '06 #1
4 1112
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)
Sep 30 '06 #2
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.
Oct 2 '06 #3
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)
Oct 2 '06 #4
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.
Oct 2 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.