String#split and capturing delimiters

A

Albert Schlef

Since what version of Ruby does "String#split /(whatever)/" returns the
delimiters in the result?

In other words, since what version it's possible, as in Perl, to put
parentheses is the regexp and have them returned?

(I'm using Ruby 1.8)

I've looked into the documentation of String#split, but it doens't
mention this feature, so I'm asking you.


<rant>
That's exasperating. In the past I used to love Ruby. But nowadays you
have to be a lawyer, or a historion, if you want to use it. There are
several "version 1.8" with different APIs and whenever you want to use
some feature you're worried perhaps it won't be supported by whoever
runs your program. "Writing Ruby is like writing literature" my foot.
</rant>
 
A

Albert Schlef

Yukihiro said:
|Since what version of Ruby does "String#split /(whatever)/" returns the
|delimiters in the result?

From the beginning. It has been there at least since 0.49 back in
July 1994, which is the oldest source code available at hand, far
before the public release.

Thanks!

(It's just that not very long ago I've read in some CHNAGELOG something
along the line of "now String#split behaves more like Perl's", and this
caused me to have a second thought before using the "capturing"
feature.)

|That's exasperating. In the past I used to love Ruby. But nowadays you
|have to be a lawyer, or a historion, if you want to use it.

That's unfortunate. I guess you've changed the attitude toward the
language, nowadays.

I wish to apologize for my rant. What I wrote was merely "air venting";
it wasn't actually about Ruby. I utilized the fact that Ruby-talk isn't
only for getting technical answers but also for "hugs" in times of need,
if you know what I mean. I didn't mean for what I wrote to be taken
[very] seriously. Sorry. Well, I hope whis shall be a lesson for me.
 
A

Aldric Giacomoni

Albert said:
I wish to apologize for my rant. What I wrote was merely "air venting";
it wasn't actually about Ruby. I utilized the fact that Ruby-talk isn't
only for getting technical answers but also for "hugs" in times of need,
if you know what I mean. I didn't mean for what I wrote to be taken
[very] seriously. Sorry. Well, I hope whis shall be a lesson for me.

When you scream in your own room, your neighbors hear you.
When you scream on the internet, Matz hears you too.
 
R

Rajinder Yadav

I wish to apologize for my rant. What I wrote was merely "air venting";
it wasn't actually about Ruby. I utilized the fact that Ruby-talk isn't
only for getting technical answers but also for "hugs" in times of need,
if you know what I mean.

I do, here you go XOXOXOXO ;)

I didn't mean for what I wrote to be taken
[very] seriously.

just a little serious then?

Sorry. Well, I hope whis shall be a lesson for me.


--
Kind Regards,
Rajinder Yadav

http://DevMentor.org

Do Good! - Share Freely, Enrich and Empower people to Transform their lives.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top