ruby on rails - How can I create a nokogiri case insensitive text * search? -



ruby on rails - How can I create a nokogiri case insensitive text * search? -

currnetly doing

words = [] words << "philip morris" words << "philip morris" words << "philip morris" words << "philip morris" word in words doc.search("[text()*='#{word}']") end

when using hpricot found downcase results within gem maintain searchs lowercase, nokogiri has been quite hard find 1 that. aware of way this? give thanks much time

the lower-case xpath function not available can utilize translate xpath 1.0 function convert text lowercase e.g. english language alphabet:

translate(text(),'abcdefghijklmnopqrstuvwxyz','abcdefghijklmnopqrstuvwxyz')

i couldn't seem utilize in combination *= operator can utilize contains substring search instead, making total thing:

doc.search("//*[contains(translate(text(),'abcdefghijklmnopqrstuvwxyz','abcdefghijklmnopqrstuvwxyz'),'philip morris')]")

ruby-on-rails nokogiri case-sensitive

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -