David Trasbo wrote:

>> as a quick example, this
>> 
>> require 'strscan'
>> s = StringScanner.new('blah {some_partial arg1:foo arg2:bar} other
>> stuff here {otherpartial arg1:baz}')
>> 
>> while s.scan_until /\{/
>>    puts "start of call"
>>    puts s.scan /\w+/
>>    s.skip /\s+/
>>    while  output=s.scan( /\w+:\w+/)
>>      puts output
>>      s.skip /\s+/
>>    end
>>    s.skip_until /\}/
>>    puts "end of call"
>> end

...

> This looks just great! I'll return when I've written a complete method.

Okay, I've been taking a look at this, and I'm facing a problem. When 
I've scanned a string I want to actually replace all the {some_partial 
foo:bar}'s with partial renderings.

I've been looking through the StringScanner documentation 
(http://www.ruby-doc.org/core/classes/StringScanner.html), but it 
doesn't seem to cover the topic of replacing matches instead of just 
extracting it, if you know what I mean.

How can I replace a {some_partial foo:bar} match with a partial 
rendering?
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to