something like eregi() in ruby?

S

Schu

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
 
S

Stefan Rusterholz

Schu said:
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
 
C

come

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
 
S

Schu

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,264
Messages
2,571,316
Members
48,002
Latest member
DoloresMan

Latest Threads

Top