Perl pos function equivalent in ruby?

What’s the equivalent to perl’s reexp pos function in ruby?

···

John Long
www.wiseheartdesign.com

I don’t know what perl’s pos does, but here.
Look at MatchData:

$ ri MatchData

···

On Thursday 08 April 2004 11:15, John W. Long wrote:

What’s the equivalent to perl’s reexp pos function in ruby?


 class: MatchData

 MatchData is the type of the special variable $~, and is the type
 of the object returned by Regexp#match and Regexp#last_match. It
 encapsulates all the results of a pattern match, results normally
 accessed through the special variables $&, $', $`, $1, $2, and so
 on. Matchdata is also known as MatchingData.

 [], begin, end, length, offset, post_match, pre_match, select,
 size, string, to_a, to_s


sdmitry -=- Dmitry V. Sabanin
MuraveyLabs.
Spam Here → postmaster@sco.com

----- “Dmitry V. Sabanin” wrote: -----

···

On Thursday 08 April 2004 11:15, John W. Long wrote:

What’s the equivalent to perl’s reexp pos function in ruby?
I don’t know what perl’s pos does, but here.
Look at MatchData:
. . .

I know about MatchData. Perl’s pos function basically returns the position
of the end of the current match. Which sounds like MatchData#end, the
difference is you can set pos so that you specify the begining in the string
of the next search. I haven’t seen anything in Ruby like this.

See http://www.perldoc.com/perl5.6/pod/func/pos.html .


John Long
www.wiseheartdesign.com

Hi,

At Fri, 9 Apr 2004 10:53:51 +0900,
John W. Long wrote in [ruby-talk:96846]:

I know about MatchData. Perl’s pos function basically returns the position
of the end of the current match. Which sounds like MatchData#end, the
difference is you can set pos so that you specify the begining in the string
of the next search. I haven’t seen anything in Ruby like this.

Use 2nd argument to String#index.

···


Nobu Nakada

nobu.nokada@softhome.net schrieb im Newsbeitrag
news:200404131520.i3DFKlQN003599@sharui.nakada.niregi.kanuma.tochigi.jp…

Hi,

At Fri, 9 Apr 2004 10:53:51 +0900,
John W. Long wrote in [ruby-talk:96846]:

I know about MatchData. Perl’s pos function basically returns the
position
of the end of the current match. Which sounds like MatchData#end, the
difference is you can set pos so that you specify the begining in the
string
of the next search. I haven’t seen anything in Ruby like this.

Use 2nd argument to String#index.

I wonder what he needs that for. Often that can be dealt with by changing
the RX in a way that String#scan is sufficient.

robert