Robert Klemme
3/3/2005 10:43:00 AM
"Ben" <bhbrinckerhoff@wustl.edu> schrieb im Newsbeitrag
news:1109823967.917281.249900@f14g2000cwb.googlegroups.com...
> I would like to use ruby to do interesting manipulations of strings.
> Ideally, I'd be able to copy multiple lines of text from a text editor,
> paste those lines of text into irb (as a string), manipulate that
> string, copy the result, and then paste it back into the original
> editor. I know that sounds like a lot of work, but the manipulations I
> want to do aren't trivial enough to do with the standard find/replace
> features of most editors.
>
> For instance, (this is kind of contrived) but say I wanted to take any
> answers to this post, and make the first and last letter of each word
> uppercase or something and then save that text in an email.
>
> Is there a way to paste multiple lines of text into irb and save them
> as a single string value? I tried using 'here documents' but that
> didn't work.
>
> By the way, I'm using FXirb since I'm runnign windows and cmd.exe isn't
> great about copying/pasting in general. Thanks.
>
> Ben
You can use here documents for that:
10:06:42 [source]: irbs
>> s=<<EOS
I would like to use ruby to do interesting manipulations of strings.
Ideally, I'd be able to copy multiple lines of text from a text editor,
paste those lines of text into irb (as a string), manipulate that
string, copy the result, and then paste it back into the original
editor. I know that sounds like a lot of work, but the manipulations I
want to do aren't trivial enough to do with the standard find/replace
features of most editors.
EOS
=> "I would like to use ruby to do interesting manipulations of
strings.\nIdeally, I'd be able to copy multiple lines of text from a text
editor,\npas
te those lines of text into irb (as a string), manipulate that\nstring,
copy the result, and then paste it back into the original\neditor. I know
that
sounds like a lot of work, but the manipulations I\nwant to do aren't
trivial enough to do with the standard find/replace\nfeatures of most
editors.n"
>> s.tr 'A-Z', 'a-z'
=> "i would like to use ruby to do interesting manipulations of
strings.\nideally, i'd be able to copy multiple lines of text from a text
editor,\npas
te those lines of text into irb (as a string), manipulate that\nstring,
copy the result, and then paste it back into the original\neditor. i know
that
sounds like a lot of work, but the manipulations i\nwant to do aren't
trivial enough to do with the standard find/replace\nfeatures of most
editors.n"
>> exit
11:42:09 [source]:
Kind regards
robert