Thanks,
Very helpful. DD ________________________________ From: watir-general@googlegroups.com [mailto:watir-gene...@googlegroups.com] On Behalf Of Andy Sipe Sent: Wednesday, January 21, 2009 12:07 PM To: watir-general@googlegroups.com Subject: [wtr-general] Re: How can I use a variable in the following $ie.div(:text,/variable_name/) You can also use interpolation to do it shorter: myvar = .... puts $ie.div(:text, /#{myvar}/) In either case, any regex reserved character will either have to be stripped or escaped to avoid out right errors like with the ( or weird matches. Some of those characters are: ( ) [ ] * . - ^ $ There are more and depending on where they occur in your search string they may cause more or less or no damage. -andy On Wed, Jan 21, 2009 at 12:59 PM, Moochie <dduph...@redbrickhealth.com> wrote: I got it. if message.index("*") != nil myvar = message[0,message.index("*")].to_s regxmyvar = Regexp.new myvar puts $ie.div(:text,regxmyvar) end It failed if If my string end with '(' so I'm guessing special characters have to be substituted. On Jan 21, 11:37 am, Moochie <dduph...@redbrickhealth.com> wrote: > I have a message that appears with a different number at the end, > > (*) wild cards - where the number would be > Message = You have successfully saved the new screening data. (ID = > ***) > > #Check to see if * (wild card exist) > if message.index("*") != nil > #Formats string to ignore wild card text and anything after > that. > message = message[0,message.index("*")] > #Try to find the message using formated - Fails here > puts $ie.div(:text,eval("/"+message+"/")) > end --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Watir General" group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~----------~----~----~----~------~----~------~--~---