What does this regexp do?

M

Mark Thomas

I can't figure out what this does:
 >> "1\n2\n3\n"[ /.\Z?/ ]
=> ""

I would expect it to output "1", just as:
 >> "1\n2\n3\n"[ /.(\Z)?/ ]
=> "1"

Is this a bug?

Neither one of those make any sense. An optional end-of-string means
nothing. That second one is the same as [/./]

-- Mark.
 

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,780
Messages
2,569,611
Members
45,270
Latest member
TopCryptoTwitterChannels_

Latest Threads

Top