Page 1 of 1

split question

Posted: Tue Oct 27, 2009 1:05 pm
by gerry.odea
I'm trying to do the following and it's not working. Can you tell me what I am doing wrong?

<$dmozdir = /Top/Arts>
<split "/" $dmozdir><$dirq = $ret>
dirq=$dirq

it is giving me dirq=

when I was expecting it to give me dirq= " Top Arts"
and what if I just wanted to pull out the "Arts" portion is there a way to pull the last variable of $dmozdir into $dirq like if I had /Top/Arts/Movies all I want is the last "Movies"

split question

Posted: Tue Oct 27, 2009 1:43 pm
by mark
That will give you an array of 3 items, "" "Top" and "Arts". <loop> over $ret to see them all.

split question

Posted: Tue Oct 27, 2009 1:44 pm
by mark
<rex "[^/]+>>=" $dmozdir><$last=$ret>

Or, if you're using the split data for other things too
<split...>
<loop max=1 rev $ret><$last=$ret></loop>

split question

Posted: Tue Oct 27, 2009 2:04 pm
by gerry.odea
Thank you Mark! I actually just found you answered a similar post and found the answer.
<rex "[^/]+>>=" $dmozdir><$dirq = $ret>