[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

something like eregi() in ruby?

Schu

8/23/2007 9:24:00 AM

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

3 Answers

Stefan Rusterholz

8/23/2007 11:46:00 AM

0

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
--
Posted via http://www.ruby-....

come

8/23/2007 11:57:00 AM

0

On 23 ao?t, 11:23, Schu <use...@vista-development.net> 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


Schu

8/23/2007 2:13:00 PM

0

> 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!