On 04.05.2008 15:21, [email protected] wrote:
and post_match? I tried calling these methods without any qualifiers
not yield what you expect:
irb(main):008:0> /a(.)*/ =~ “abcdef”
IMHO it is generally a bad idea to use grouping in the way you do it
because it will capture a lot that you are not interested in. It seems
you might rather want “(.*)”.
In my guess /b/ =~ “abc” is what sets $~ variable. Since I am not
using that statement anywhere that variable is not set at all.
That’s complete nonsense. Did you try it out? I guess not. Come on,
don’t be so lazy.
I am doing the matching in a case statement. As a result I am not able
to do something like $~.pre_match. I am not fond of $1, $2, etc
variables. I feel comfortable using the instance variables pre_match
pre_match and post_match are not instance variables but methods of class
But you solved the first problem I was trying to solve I was using
(.)* instead of (.) and I couldn’t get what I wanted. (.) is what I
needed. Thanks so much for that. Now I can use $1, $2 at least if not
pre_match and post_match.
irb(main):007:0> /b/ === “abc”