Re: iterate chars in a string



a="123"

0.upto(a.length) { |i| puts a[i..i] }


On 12/20/05, shinya <piccionevolante@xxxxxxxxx> wrote:
> Hi there!
> I'm a ruby newbie, and I'm searching for a way to iterate every char in
> a string, but I cannot find any easy way. My problem is to look at every
> char in a string and match it with some known letter.
> I use the String#each_byte iterator for now, but it still be a poor
> solution :/
> Thanks,
>
> shinya.
>
>


--
Into RFID? www.rfidnewsupdate.com Simple, fast, news.


.



Relevant Pages

  • Re: Finding substring in character array
    ... It works with a character array instead. ... is that there's no way to make one without already having all the characters in an array which then gets copied into the string. ... whereas you could fill all 1 MB with a char[]. ... If he insists on searching a char, i would suggest he reads up on the Boyer-Moore string searching algorithm. ...
    (comp.lang.java.programmer)
  • Re: [newbie] Best way to search for binary data
    ... [string searching ... ... > searching random bytes. ... algorithms are usually preferred to the Knuth-Morris-Pratt algorithm. ... void init_search(const char *string) ...
    (microsoft.public.vc.language)
  • Re: Input file *.txt to dialog box
    ... Here's how you search for a complete string. ... are searching for in a char array. ... current character in the string. ...
    (microsoft.public.vc.mfc)
  • Re: iterate chars in a string
    ... and I'm searching for a way to iterate every ... >> look at every char in a string and match it with some known letter. ... > The usual idiom is str.split.each do |character| ...
    (comp.lang.ruby)
  • iterate chars in a string
    ... I'm a ruby newbie, and I'm searching for a way to iterate every char in a string, but I cannot find any easy way. ...
    (comp.lang.ruby)