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

Using Android Volley to post an array to PHP -

python - How to add an model instance to a django queryset? -

angularjs - No 'Access-Control-Allow-Origin' error from local domain to public API -