<jbritt / ruby-doc.org> wrote in message > The other ML issue (perhaps) is that posting is not restricted to subscribers, > hence the sporadic spam that turns up. Much of it > is caught by filters befire reaching subscribers, though. Speaking of spam, I was surprised by the rejection of my email (which contained some perl code and equivalent ruby code) on the grounds of it being spam. I have included the response in its entire form below. I suspect that even this email may get rejected by the ML (becuase the code is still there ;-)). Any way, if someone can guide me so that I won't commit the same mistake twice. Thanks, -- shanko ---------------------------------------------------------------------------- -------------- Your mail is rejected for avoid to distribute commands [#Perl Code:] Original mail as follows: From owner-ruby-talk / ruby-lang.org Wed Jan 1 10:04:26 2003 Return-Path: <owner-ruby-talk / ruby-lang.org> Received: from zip.local.thomases.com (pragdave210.august.net [216.87.136.210]) by helium.ruby-lang.org (Postfix) with ESMTP id B8BA051C for <ruby-talk / ruby-lang.org>; Wed, 1 Jan 2003 10:04:23 +0900 (JST) Received: from localhost.localdomain (dave@localhost [127.0.0.1]) by zip.local.thomases.com (8.11.2/8.11.2) with ESMTP id h0114Sm02824 for <ruby-talk / ruby-lang.org>; Tue, 31 Dec 2002 19:04:28 -0600 To: ruby-talk / ruby-lang.org Path: news5.aus1.giganews.com!firehose2!nntp4!nntp3.aus1.giganews.com!border1.nntp ..aus1.giganews.com!nntp2.aus1.giganews.com!nntp.giganews.com!newsfeed.cwix.c om!news-east.rr.com!news-server.columbus.rr.com!cyclone3.kc.rr.com!news3.kc. rr.com!twister.kc.rr.com.POSTED!53ab2750!not-for-mail From: "Shashank Date" <sdate / kc.rr.com> Newsgroups: comp.lang.ruby References: <3E116DDE.972A9081 / chello.at> Subject: Re: How to translate this Perl regex Lines: 48 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: <OYqQ9.36884$eB.654418 / twister.kc.rr.com> Date: Tue, 31 Dec 2002 18:52:44 -0600 NNTP-Posting-Host: 65.30.73.197 X-Complaints-To: abuse / rr.com X-Trace: twister.kc.rr.com 1041382318 65.30.73.197 (Tue, 31 Dec 2002 18:51:58 CST) NNTP-Posting-Date: Tue, 31 Dec 2002 18:51:58 CST Xref: nntp3.aus1.giganews.com comp.lang.ruby:58986 Received: from Usenet via a Usenet to mail gateway located at pragprog.com. This service provided as a courtesy to the ruby-talk mailing list. If this message is SPAM, its ultimate origin is Usenet, not this gateway program. All subscribers to the ruby-talk mailing list agree to receive the Usenet postings made to comp.lang.ruby via this gateway. Please see http://www.ruby-lang.org/ruby-talk-usenet-policy.html. X-From-Usenet: see Received: header above. X-rubymirror: yes X-Spam-Status: No, hits=1.5 required=5.0 tests=FORGED_RCVD_FOUND,RCVD_IN_ORBZ version=2.20 X-Spam-Level: * #Perl Code: sub foo { (uc shift).(uc shift); } my $s = 'aaabccc[abc][ab]bc'; $s =~ s/(a+)b(c*)/&foo($1,$2)/ge; print $s."\n"; # --------------------------------------------------- # Ruby Code: def foo(a,b) a.upcase + b.upcase end s = "aaabccc[abc][ab]bc" puts s.gsub!(/(a+)b(c*)/) { foo($1, $2) } HTH, -- shanko "Helmut Leitner" <helmut.leitner / chello.at> wrote in message news:3E116DDE.972A9081 / chello.at... > Someone said that Ruby can do anything that Perl does. > How would you write this Perl regex > > $s =~ s/(pat1+)pat2(pat3*)/&foo($1,$2)/ge; > > in Ruby? > > It > - does a global replace (/g) in one sweep > - executes code (calls function) to create the replacement string (/e) > - uses parts of the searched patterns (groupings) as parameters to foo > > My books > - Ruby in a Nutshell > - The Ruby Way > are very brief with respect to regexs and don't give > me a clue how to do this. > > -- > Helmut Leitner leitner / hls.via.at > Graz, Austria www.hls-software.com --ruby-talk / ruby-lang.org, Be Seeing You! ************************************************************ If you have any questions or problems, please contact ruby-talk-admin / ruby-lang.org ************************************************************