Hey goodevening, I am struggling with this: i have a long string a982k298e863q982 I am wondering if it would be possible (i''ve searched but no luck) to use split to parse the 4 products contained in this string to get ["a982","k298","e863","q982"] every product is alway''s 4 characters long. Is string.split the way to go- or should I just process the string character by character? Thanks a million!! kind regards, Marco Kotrotsos --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
''a982k298e863q982''.split(/(.{4})/).without('''') is the only thing I can think of for now using split The other solution being of course: ''a982k298e863q982''.toArray().inGroupsOf(4).invoke(''join'', '''') Hope this helps, Tobie On Jun 24, 4:06 pm, Marco Kotrotsos <m...-TfQLmxuAFIs@public.gmane.org> wrote:> Hey goodevening, > > I am struggling with this: > > i have a long string > > a982k298e863q982 > > I am wondering if it would be possible (i''ve searched but no luck) to > use split to parse the 4 products contained in this string to get > > ["a982","k298","e863","q982"] > > every product is alway''s 4 characters long. > Is string.split the way to go- or should I just process the string > character by character? > > Thanks a million!! > kind regards, > Marco Kotrotsos--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
hey great- thanks... i''m getting an error though split.rb:1: undefined method `without'' for ["", "a982", "", "k298", "", "e863", "", "q982"]:Array (NoMethodError) should i include a library? What does .without do exactly? again , thanks alot! Marco On Jun 24, 10:25 pm, tobie <tobie.lan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> ''a982k298e863q982''.split(/(.{4})/).without('''') is the only thing I can > think of for now using split > > The other solution being of course: > > ''a982k298e863q982''.toArray().inGroupsOf(4).invoke(''join'', '''') > > Hope this helps, > > Tobie > > On Jun 24, 4:06 pm, Marco Kotrotsos <m...-TfQLmxuAFIs@public.gmane.org> wrote: > > > > > Hey goodevening, > > > I am struggling with this: > > > i have a long string > > > a982k298e863q982 > > > I am wondering if it would be possible (i''ve searched but no luck) to > > use split to parse the 4 products contained in this string to get > > > ["a982","k298","e863","q982"] > > > every product is alway''s 4 characters long. > > Is string.split the way to go- or should I just process the string > > character by character? > > > Thanks a million!! > > kind regards, > > Marco Kotrotsos- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
well... this *is* the prototype mailing list... On Jun 24, 4:45 pm, Marco Kotrotsos <m...-TfQLmxuAFIs@public.gmane.org> wrote:> hey great- thanks... > > i''m getting an error though > > split.rb:1: undefined method `without'' for ["", "a982", "", "k298", > "", "e863", "", "q982"]:Array (NoMethodError) > > should i include a library? What does .without do exactly? > again , thanks alot! > Marco > > On Jun 24, 10:25 pm, tobie <tobie.lan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> ''a982k298e863q982''.split(/(.{4})/).without('''') is the only thing I can > > think of for now using split > > > The other solution being of course: > > > ''a982k298e863q982''.toArray().inGroupsOf(4).invoke(''join'', '''') > > > Hope this helps, > > > Tobie > > > On Jun 24, 4:06 pm, Marco Kotrotsos <m...-TfQLmxuAFIs@public.gmane.org> wrote: > > > > Hey goodevening, > > > > I am struggling with this: > > > > i have a long string > > > > a982k298e863q982 > > > > I am wondering if it would be possible (i''ve searched but no luck) to > > > use split to parse the 4 products contained in this string to get > > > > ["a982","k298","e863","q982"] > > > > every product is alway''s 4 characters long. > > > Is string.split the way to go- or should I just process the string > > > character by character? > > > > Thanks a million!! > > > kind regards, > > > Marco Kotrotsos- Hide quoted text - > > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I get it now... you''re asking for this in Ruby... wrong channel! (I obviously answered in JavaScript this is the Prototye mailing list!) On Jun 24, 5:01 pm, tobie <tobie.lan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> well... this *is* the prototype mailing list... > > On Jun 24, 4:45 pm, Marco Kotrotsos <m...-TfQLmxuAFIs@public.gmane.org> wrote: > > > hey great- thanks... > > > i''m getting an error though > > > split.rb:1: undefined method `without'' for ["", "a982", "", "k298", > > "", "e863", "", "q982"]:Array (NoMethodError) > > > should i include a library? What does .without do exactly? > > again , thanks alot! > > Marco > > > On Jun 24, 10:25 pm, tobie <tobie.lan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> ''a982k298e863q982''.split(/(.{4})/).without('''') is the only thing I can > > > think of for now using split > > > > The other solution being of course: > > > > ''a982k298e863q982''.toArray().inGroupsOf(4).invoke(''join'', '''') > > > > Hope this helps, > > > > Tobie > > > > On Jun 24, 4:06 pm, Marco Kotrotsos <m...-TfQLmxuAFIs@public.gmane.org> wrote: > > > > > Hey goodevening, > > > > > I am struggling with this: > > > > > i have a long string > > > > > a982k298e863q982 > > > > > I am wondering if it would be possible (i''ve searched but no luck) to > > > > use split to parse the 4 products contained in this string to get > > > > > ["a982","k298","e863","q982"] > > > > > every product is alway''s 4 characters long. > > > > Is string.split the way to go- or should I just process the string > > > > character by character? > > > > > Thanks a million!! > > > > kind regards, > > > > Marco Kotrotsos- Hide quoted text - > > > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
<slap head> i''m sorry- wrong group- but it was very helpfull anyways! Thanks Marco On Jun 24, 11:01 pm, tobie <tobie.lan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> well... this *is* the prototype mailing list... > > On Jun 24, 4:45 pm, Marco Kotrotsos <m...-TfQLmxuAFIs@public.gmane.org> wrote: > > > > > hey great- thanks... > > > i''m getting an error though > > > split.rb:1: undefined method `without'' for ["", "a982", "", "k298", > > "", "e863", "", "q982"]:Array (NoMethodError) > > > should i include a library? What does .without do exactly? > > again , thanks alot! > > Marco > > > On Jun 24, 10:25 pm, tobie <tobie.lan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> ''a982k298e863q982''.split(/(.{4})/).without('''') is the only thing I can > > > think of for now using split > > > > The other solution being of course: > > > > ''a982k298e863q982''.toArray().inGroupsOf(4).invoke(''join'', '''') > > > > Hope this helps, > > > > Tobie > > > > On Jun 24, 4:06 pm, Marco Kotrotsos <m...-TfQLmxuAFIs@public.gmane.org> wrote: > > > > > Hey goodevening, > > > > > I am struggling with this: > > > > > i have a long string > > > > > a982k298e863q982 > > > > > I am wondering if it would be possible (i''ve searched but no luck) to > > > > use split to parse the 4 products contained in this string to get > > > > > ["a982","k298","e863","q982"] > > > > > every product is alway''s 4 characters long. > > > > Is string.split the way to go- or should I just process the string > > > > character by character? > > > > > Thanks a million!! > > > > kind regards, > > > > Marco Kotrotsos- Hide quoted text - > > > > - Show quoted text -- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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 25, 6:25 am, tobie <tobie.lan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> ''a982k298e863q982''.split(/(.{4})/).without('''') is the only thing I can > think of for now using split > > The other solution being of course: > > ''a982k298e863q982''.toArray().inGroupsOf(4).invoke(''join'', '''')It seems much simpler to use the native String.prototype.match method: ''a982k298e863q982''.match(/\w{4}/g); -- 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 -~----------~----~----~----~------~----~------~--~---
Thanks Rob. I always do this. Forget about using match in these cases. Weird. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---