Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
search query
K. R.
2/18/2008 4:23:00 PM
hi @ all
Has anyone an idea, how I can put a query into a array with regex like
the example below:
-> query = 'ruby + "ruby on rails"'
-> array = ["ruby ruby on rails", "ruby", "ruby on rails"]
--
Posted via
http://www.ruby-...
.
1 Answer
yermej
2/19/2008 4:19:00 PM
0
On Feb 18, 10:22 am, "K. R." <m...@palstek.ch> wrote:
> hi @ all
> Has anyone an idea, how I can put a query into a array with regex like
> the example below:
>
> -> query = 'ruby + "ruby on rails"'
> -> array = ["ruby ruby on rails", "ruby", "ruby on rails"]
> --
> Posted via
http://www.ruby-...
.
In the given case, you can use this:
array = query.split(/\s+\+\s+/).map {|str| str.tr('"', '')}
array.unshift(array.join(' '))
This should give you a starting point. However, depending on the
allowed syntax for your queries, this may not work in all cases. E.g.,
if you don't require whitespace on either side of the '+', the first
line should probably be:
array = query.split(/\+/).map {|str| str.strip.tr('"', '')}
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
search query
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password