Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > behaviour change of String#gsub(pattern) {|m| ... } for ruby 1.9/ruby2?

Reply
Thread Tools

behaviour change of String#gsub(pattern) {|m| ... } for ruby 1.9/ruby2?

 
 
David Garamond
Guest
Posts: n/a
 
      11-20-2003
String#gsub(pattern) {|m| ... }

It really would be nice to get match data in 'm', but this would surely
break _a lot_ of scripts. How about String#regsub, #regsub!, #resub,
#resub! ? What do others think?

--
dave


 
Reply With Quote
 
 
 
 
Yukihiro Matsumoto
Guest
Posts: n/a
 
      11-20-2003
Hi,

In message "behaviour change of String#gsub(pattern) {|m| ... } for ruby 1.9/ruby2?"
on 03/11/20, David Garamond <lists@zara.6.isreserved.com> writes:

|String#gsub(pattern) {|m| ... }
|
|It really would be nice to get match data in 'm', but this would surely
|break _a lot_ of scripts. How about String#regsub, #regsub!, #resub,
|#resub! ? What do others think?

Sounds nice. The only reason for the current behavior is that sub
predates MatchData. But we have to define migration path.

matz.


 
Reply With Quote
 
 
 
 
Florian Gross
Guest
Posts: n/a
 
      11-21-2003
Yukihiro Matsumoto wrote:

> Hi,


Moin!

> |String#gsub(pattern) {|m| ... }
> |
> |It really would be nice to get match data in 'm', but this would surely
> |break _a lot_ of scripts. How about String#regsub, #regsub!, #resub,
> |#resub! ? What do others think?
>
> Sounds nice. The only reason for the current behavior is that sub
> predates MatchData. But we have to define migration path.


I like this, because matz told me I shouldn't be using $1 in the
gsub-block and there's no way to not do so right now.

Add a MatchData#to_str and it should work for most cases. We could give
a warning for cases where scripts would still be broken by this chance.

Regards,
Florian Gross



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
debugger behaviour different to execution behaviour Andy Chambers Java 1 05-14-2007 09:51 AM
Signal handling behaviour change after ruby upgrade andrew@walrond.org Ruby 6 10-30-2006 10:22 AM
A Paradise DNS address change? What change? There was no change. Tony Neville NZ Computing 7 09-22-2006 01:02 PM
#!/usr/bin/ruby , #!/usr/bin/ruby -w , #!/usr/bin/ruby -T?, #!/usr/bin/ruby -T1... anne001 Ruby 1 04-23-2006 03:02 PM
how to change default ENTER key behaviour on a button/form Flip ASP .Net 2 11-18-2004 04:21 AM



Advertisments