View Full Version : Split words

09-26-2007, 06:03 PM

In general when we split words we use:

xwords= split(ywords," ")

But, using a table, for example, tableA, where there is a column named "names" where the strings are single words. As I split each word in this way:

night (ni,ig,gh,ht)
achieve (ac,ch,hi,ie,ev,ve)

Thanks in advance,


09-26-2007, 07:02 PM

Were you meaning to ask a question?

09-26-2007, 09:13 PM
I think his question is, how do you split a word based on certain number of letters.

Silly question -- WHY would you ever want to do this?

But, I digress - You would need to use many different functions to accomplish this task:

1) MID
2) LEN
3) FOR NEXT loop
4) Response.write

This works, although that is based on whether or not I am correctly interpreting your question:

<% function splitLetters(strWord)
letterCount = len(strWord)
for x=1 to letterCount-1
if Eval(x/2) = Eval(2/x) then
strWord2 = strWord2 & mid(mid(strWord,x,2),x-1,3) & ","
strWord2 = strWord2 & mid(strWord,x,2) & ","
end if
splitLetters = left(strWord2,len(strWord2)-1)
end function %>

<p>Night: <%= splitLetters("night") %></p>
<p>Achieve: <%= splitLetters("achieve") %></p>
<p>Astronomy: <%= splitLetters("Astronomy") %></p>
<p>Coding: <%= splitLetters("Coding") %></p>
<p>Forums: <%= splitLetters("Forums") %></p>
<p>luigicannavaro <%= splitLetters("luigicannavaro") %></p>
<p>miranda: <%= splitLetters("miranda") %></p>
<p>Daemonspyre: <%= splitLetters("Daemonspyre") %></p>

Things you have to watch out for: SPACES, Case SeNsItIvItY, NULL values, Empty strings.


09-27-2007, 01:18 PM
Thanks a lot!

Yes, it is possible do a lot of things using these functions.

The script works fine and works like I want.



10-07-2007, 11:25 PM
So how about thanking him for this helpfull post?
I'm sure he'd like that ;)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum