Hi, I have a string of numbers that i''m turning in to an array with $A, like so: var string = ''12345678910''; var arr = $A(string); Problem is i need to deal with double figures, so in the example the problem comes when you get to 10 because $A just splits on every character so i get 1,2,3,4,5,6,7,8,1,0 where i really want 1,2,3,4,5,6,7,8,9,10. So is there any way i can specify something to split the string on....like if i had 1*2*3*4*5*6*7*8*9*10 and then split it on the *??? Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, You''re looking for JavaScript''s String#split method: http://www.w3schools.com/jsref/jsref_split.asp Hope this helps, -- T.J. Crowder tj / crowder software / com On Jun 23, 10:06 am, elduderino <jamesfiltn...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Hi, I have a string of numbers that i''m turning in to an array with > $A, like so: > > var string = ''12345678910''; > var arr = $A(string); > > Problem is i need to deal with double figures, so in the example the > problem comes when you get to 10 because $A just splits on every > character so i get > 1,2,3,4,5,6,7,8,1,0 where i really want 1,2,3,4,5,6,7,8,9,10. > > So is there any way i can specify something to split the string > on....like if i had 1*2*3*4*5*6*7*8*9*10 and then split it on the > *??? > > Thanks!--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
$A(''1*2*3*4*5*6*7*8*9*10''.split(''*'')) -- blog: www.lucaguidi.com Pro-Netics: www.pro-netics.com Sourcesense - making sense of Open Source: www.sourcesense.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
2008/6/23 elduderino <jamesfiltness-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>:> > Hi, I have a string of numbers that i''m turning in to an array with > $A, like so: > > var string = ''12345678910''; > var arr = $A(string); > > Problem is i need to deal with double figures, so in the example the > problem comes when you get to 10 because $A just splits on every > character so i get > 1,2,3,4,5,6,7,8,1,0 where i really want 1,2,3,4,5,6,7,8,9,10. > > So is there any way i can specify something to split the string > on....like if i had 1*2*3*4*5*6*7*8*9*10 and then split it on the > *??? > > Thanks! > > >Try ... $w(''1 2 3 4 5 6 7 8 9 10''); $w "Splits a string into an Array, treating all whitespace as delimiters. Equivalent to Ruby''s %w{foo bar} or Perl''s qw(foo bar)." -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Jun 23, 7:06 pm, elduderino <jamesfiltn...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Hi, I have a string of numbers that i''m turning in to an array with > $A, like so: > > var string = ''12345678910''; > var arr = $A(string); > > Problem is i need to deal with double figures, so in the example the > problem comes when you get to 10 because $A just splits on every > character so i get > 1,2,3,4,5,6,7,8,1,0 where i really want 1,2,3,4,5,6,7,8,9,10.Then: var arr = [1,2,3,4,5,6,7,8,9,10]; will do the job unambiguously.> So is there any way i can specify something to split the string > on....like if i had 1*2*3*4*5*6*7*8*9*10 and then split it on the > *???If you are to use any character, why not use a comma and an array literal? -- Rob --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Guys....thanks for the replies. Of course....split will do just the trick but i also forgot about $w....which will do even better i think s On Jun 23, 12:52 pm, RobG <rg...-AFFH1GffN5hPR4JQBCEnsQ@public.gmane.org> wrote:> On Jun 23, 7:06 pm, elduderino <jamesfiltn...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > Hi, I have a string of numbers that i''m turning in to an array with > > $A, like so: > > > var string = ''12345678910''; > > var arr = $A(string); > > > Problem is i need to deal with double figures, so in the example the > > problem comes when you get to 10 because $A just splits on every > > character so i get > > 1,2,3,4,5,6,7,8,1,0 where i really want 1,2,3,4,5,6,7,8,9,10. > > Then: > > var arr = [1,2,3,4,5,6,7,8,9,10]; > > will do the job unambiguously. > > > So is there any way i can specify something to split the string > > on....like if i had 1*2*3*4*5*6*7*8*9*10 and then split it on the > > *??? > > If you are to use any character, why not use a comma and an array > literal? > > -- > Rob--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
You might want to look into range too: $R(1, 10) Best, Tobie On Jun 23, 2:26 pm, elduderino <jamesfiltn...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Hi Guys....thanks for the replies. Of course....split will do just the > trick but i also forgot about $w....which will do even better i think > s > > On Jun 23, 12:52 pm, RobG <rg...-AFFH1GffN5hPR4JQBCEnsQ@public.gmane.org> wrote: > > > On Jun 23, 7:06 pm, elduderino <jamesfiltn...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > Hi, I have a string of numbers that i''m turning in to an array with > > > $A, like so: > > > > var string = ''12345678910''; > > > var arr = $A(string); > > > > Problem is i need to deal with double figures, so in the example the > > > problem comes when you get to 10 because $A just splits on every > > > character so i get > > > 1,2,3,4,5,6,7,8,1,0 where i really want 1,2,3,4,5,6,7,8,9,10. > > > Then: > > > var arr = [1,2,3,4,5,6,7,8,9,10]; > > > will do the job unambiguously. > > > > So is there any way i can specify something to split the string > > > on....like if i had 1*2*3*4*5*6*7*8*9*10 and then split it on the > > > *??? > > > If you are to use any character, why not use a comma and an array > > literal? > > > -- > > Rob--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---