Michael Pavling wrote in post #1074025:
> "match" is a good place to start.
>
> class MyModel < AR::Base
> # my model has a big string field called "note_details", from
> # which I want to extract the username and hostname values
>
> def username
> note_details.match(/The (\S*) is logged in via (\S*)/)[1]
> end
>
> def hostname
> note_details.match(/The (\S*) is logged in via (\S*)/)[2]
> end
> end
>
Thanks Michael, that worked a treat!
--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment