I've created a service to use primarily in a browser for searching IMDB, so instead of copying and pasting the film's name I just select the text and run the service I created which will automatically search IMDB for the selected text. This works perfect.
I was hoping to do the same for Wikipedia and so i've been trying to modify the same service but have come across a problem. The search query places a "+" between each word.
This doesn't work for Wikipedia. They place underscores between their words.
I wondered how I can substitute the + for _? This is what I currently have
open "https://en.wikipedia.org/wiki/$(ruby -rcgi -e 'print CGI.escape $<.read.chomp')"
Kinds regards and Merry Christmas :)
You can substitute every space for underscore with the gsub() command before the escape command.
open "https://en.wikipedia.org/wiki/$(ruby -rcgi -e 'print CGI.escape $<.read.chomp.gsub(" ", "_")')"