Something like eregi() in ruby?

hi people!

i can’t info on that - is there anything comparable to the
functionality of ereg() or preg_match() of PHP under ruby?

thx in advance
S

Schu wrote:

hi people!

i can’t info on that - is there anything comparable to the
functionality of ereg() or preg_match() of PHP under ruby?

thx in advance
S

Look at the methods String and Regexp provide.
Like String#match, Regexp#match, String#=~, Regexp#=~, String#scan,
String#sub, String#gsub.
Also take a look at MatchData (returned by the #match methods).
For case insensitivity, use the i switch, example: /foo/i, or %r{foo}i
(/regex/ is a regex literal which does the same as Regexp.new(‘regex’),
%r{regex} is just a different way to write it).

Regards
Stefan

On 23 août, 11:23, Schu [email protected] wrote:

hi people!

i can’t info on that - is there anything comparable to the
functionality of ereg() or preg_match() of PHP under ruby?

thx in advance
S

Hi,

Of course :

I don’t know PHP but I think match is the closer equivalent of ereg

re.match(string) or string.match(re) => object matchdata

This object matchdata has methods like pre_match and post_match.

Come

Of course :

I don’t know PHP but I think match is the closer equivalent of ereg

re.match(string) or string.match(re) => object matchdata

This object matchdata has methods like pre_match and post_match.

thanks a lot, that’s exactly what i was looking for!