ruby-dev summary 25709-25740

T

Takaaki Tateishi

Here is a summary of articles posted to ruby-dev ML last week.

[ruby-dev:25713] pthread trouble on sighandler

Nagai proposed a solution on signal handlers of ruby that enables
native thread, and it was tentatively applied to ruby-1.9.
That solution enables the ruby to ignore signals which are caused
by other threads.

[ruby-dev:25726] named capture

Nishiyama proposed that MatchData#[] receives a symbol and a string, and
returns matched data which is indicated by a label on a regular expression.
That proposal is for a ruby with Oniguruma as a regular expression engine,
as Oniguruma has a feature called "named capture" to specify matched strings
using labels.
 
D

Daniel Berger

Takaaki said:
[ruby-dev:25726] named capture

Nishiyama proposed that MatchData#[] receives a symbol and a string, and
returns matched data which is indicated by a label on a regular expression.
That proposal is for a ruby with Oniguruma as a regular expression engine,
as Oniguruma has a feature called "named capture" to specify matched strings
using labels.

Can someone please provide some sample code for this? I'm not sure I
get it.

Thanks.

Dan
 
T

ts

D> Can someone please provide some sample code for this? I'm not sure I
D> get it.

uln% ruby -e '/(?<name>x+)/ =~ "xxxx" ; p $~[0]'
"xxxx"
uln%

uln% ruby -e '/(?<name>x+)/ =~ "xxxx" ; p $~[:name]'
-e:1:in `[]': cannot convert Symbol into Integer (TypeError)
from -e:1
uln%



Guy Decoux
 

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,800
Messages
2,569,657
Members
45,416
Latest member
MyraTrotte
Top