Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Split words

  1. #1
    Regular Coder luigicannavaro's Avatar
    Join Date
    Aug 2007
    Posts
    150
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Thumbs down Split words

    Hi,

    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,

    Luigi

  • #2
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,062
    Thanks
    4
    Thanked 8 Times in 8 Posts
    ????

    Were you meaning to ask a question?

  • #3
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    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:

    Code:
    <% 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) & ","
    		else
    			strWord2 = strWord2 & mid(strWord,x,2) & ","
    		end if
    	next
    	'
    	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.

    HTH!
    To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
    Please, if you found my post helpful, pay it forward. Go and help someone else today.

  • #4
    Regular Coder luigicannavaro's Avatar
    Join Date
    Aug 2007
    Posts
    150
    Thanks
    11
    Thanked 0 Times in 0 Posts
    Thanks a lot!

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

    The script works fine and works like I want.

    Best

    Luigi

  • #5
    Senior Coder BarrMan's Avatar
    Join Date
    Feb 2005
    Location
    Israel.
    Posts
    1,644
    Thanks
    69
    Thanked 83 Times in 82 Posts
    So how about thanking him for this helpfull post?
    I'm sure he'd like that

  • Users who have thanked BarrMan for this post:

    Daemonspyre (10-08-2007)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •