[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Need regex to match "^\n"

Michael Campbell

7/7/2003 5:53:00 PM

> Jim Freeze <jim@freeze.org> writes:
> > > Just remember, string goes on the left, regex goes on the right.
> > >
> >
> > Actually, it doesn't matter, but Matz prefers the regex on the left.
>
> Heh. Learn something new every day.


I always wondered about that. It "reads" funny to my brain that way but I
wasn't consulted. =D Too, it's easy enough to do either direction, so no
worries.


3 Answers

Brian Candler

7/7/2003 6:07:00 PM

0

On Tue, Jul 08, 2003 at 02:52:44AM +0900, Michael Campbell wrote:
> > Jim Freeze <jim@freeze.org> writes:
> > > > Just remember, string goes on the left, regex goes on the right.
> > > >
> > >
> > > Actually, it doesn''t matter, but Matz prefers the regex on the left.
> >
> > Heh. Learn something new every day.
>
>
> I always wondered about that. It "reads" funny to my brain that way but I
> wasn''t consulted. =D Too, it''s easy enough to do either direction, so no
> worries.

I think regex-on-right is a perlism, but even in Ruby if you use =~ on two
strings, it''s the one on the right which is treated as a regex:

irb(main):003:0> "abc" =~ "b"
=> 1
irb(main):004:0> "b" =~ "abc"
=> nil

Cheers,

Brian.

Dossy

7/7/2003 6:12:00 PM

0

On 2003.07.08, Michael Campbell <michael_s_campbell@yahoo.com> wrote:
> > Jim Freeze <jim@freeze.org> writes:
> > > > Just remember, string goes on the left, regex goes on the right.
> > > >
> > >
> > > Actually, it doesn''t matter, but Matz prefers the regex on the left.
> >
> > Heh. Learn something new every day.
>
> I always wondered about that. It "reads" funny to my brain that way but I
> wasn''t consulted. =D Too, it''s easy enough to do either direction, so no
> worries.

Maybe it has to do with Matz being used to reading RTL and not LTR like
us ''merkins.

-- Dossy

--
Dossy Shiobara mail: dossy@panoptic.com
Panoptic Computer Network web: http://www.pan...
"He realized the fastest way to change is to laugh at your own
folly -- then you can let go and quickly move on." (p. 70)

Samuel Tesla

7/7/2003 6:39:00 PM

0

Brian Candler <B.Candler@pobox.com> writes:

> I think regex-on-right is a perlism, but even in Ruby if you use =~ on two
> strings, it''s the one on the right which is treated as a regex:

That''s certainly where I picked it up.