I would convert your wildcard string to a regular expression and then use that for the comparison.
Bret Moochie wrote: > If I have a cell with the following (05-07-2009 09:00 AM)) and I only > want to validate the Date and AM or PM, we use wildcards to represent > the data we doen't want to compare. Using the following function. > > excel_value = 05-07-2009 ***** AM > object_text = 05-07-2009 09:00 AM > > def format_object_text_when_wildcards_exist(excel_value,object_text) > wildcard_str = "" > index = 1 > excel_value.to_s.each_char {|x| > if x == '*' > wildcard_str = wildcard_str+","+ > index.to_s > end > index = index + 1 > } > #Remove first chacter and splits string > wildcard_str = wildcard_str[1..-1].split(',') > #Replace wild cards from the object text > index = 1 > z = 0 > value = "" > object_text.to_s.each_char {|y| > if index == wildcard_str[z].to_i > value = value + "*" > z = z +1 > else > value = value + y > end > index = index + 1 > } > return value > end > > #Call the function > cell_value = format_object_text_when_wildcards_exist > (excel_value,object_text) > > if cell_value = excel_value > puts "Pass" > else > puts "Fail" > end > > Is there a better way to do this? or a method that uses less lines of > code, please post. > > Thanks, > > > > > -- Bret Pettichord CTO, WatirCraft LLC, www.watircraft.com Lead Developer, Watir, www.watir.com Blog, www.io.com/~wazmo/blog Twitter, www.twitter.com/bpettichord Ask me about Watir training www.watircraft.com/training --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---