Frederick Cheung wrote:

>> get the regular expression right. It needs to respect multiple
>> arguments. Any suggestions?
> 
> that's the point - with stringscanner you don't need to come up with
> one giant regular expression that gets everything right

Aha! I thought you meant the RegExp#scan method.

> 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
> 
> outputs
> 
> start of call
> some_partial
> arg1:foo
> arg2:bar
> end of call
> start of call
> otherpartial
> arg1:baz
> end of call

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

-- 
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