parantheses gives you what is matched. for example you have something like this. (\d\d)-(\d) if this expression matches to 25-1 $1 gives you 25, $2 gives you 1. Since you have not parantheses in your regular expression, ruby gives you nil. You find that string but do not parse it correctly. in your case i think $ie.contains_text(/(\/25)/); puts $&
would give you correct answer. On 9/13/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > still it returns nil. the whole text I'm searching for is 1-25/25. but of > course this is dynamic. Does $& by any chance interprets and computes 1-25/25 > as nil instead? > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Bret Pettichord > Sent: Tuesday, September 13, 2005 12:34 PM > To: [email protected] > Subject: RE: [Wtr-general] check what's the content of this certain text > > > At 10:14 PM 9/12/2005, [EMAIL PROTECTED] wrote: > >hi I used this... > > > >if $ie.contains_text("/25") then puts $& end > > > >but it returns nil. don't know why. I'm assuming it will return /25 or > >rather the whole text. > > You have to use a regular expression: > > $ie.contains_text(/\/25/); puts $& > > (You have to back-quote the slash.) > > _____________________ > Bret Pettichord > www.pettichord.com > > _______________________________________________ > Wtr-general mailing list > [email protected] > http://rubyforge.org/mailman/listinfo/wtr-general > > _______________________________________________ > Wtr-general mailing list > [email protected] > http://rubyforge.org/mailman/listinfo/wtr-general > _______________________________________________ Wtr-general mailing list [email protected] http://rubyforge.org/mailman/listinfo/wtr-general
