Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h1>Basics</h1> <h3>sample string:</h3> <p><code>foo:(hello world) bar:(-{bad things}) email:something@email.tld another:weird characters +=2{-52!%#^ final:end</code></p> <h3>split with regex:</h3> <p><code>/\s+(?=\w+:)/</code></p> <h3>return array:</h3> <pre><code>[ 'foo:(hello world)', 'bar:(-{bad things})', 'email:something@email.tld', 'another:weird characters +=2{-52!%#^', 'final:end' ] </code></pre> <h3>regex explanation:</h3> <pre><code>\s+ one or more spaces (?= followed by (positive lookahead) \w+ one or more word characters : literal `:' (colon character) ) </code></pre> <h3>usage:</h3> <p>Iterate through the array, split each element at <code>:</code> (colon). The left side <code>key</code> could be used to call a function and the right side <code>value</code> could be passed as the function parameter. This should pretty much put you on track for whatever you want to do from here.</p> <h1>Example ruby usage</h1> <h3>search.rb</h3> <pre><code># Search class class Search def initialize(query) @query = query end def foo(input) "foo has #{input}" end def bar(input) "bar has #{input}" end def email(input) "email has #{input}" end def another(input) "another has #{input}" end def final(input) "final has #{input}" end def exec @query.split(/\s+(?=\w+:)/).each do |e| method, arg = e.split(/:/) puts send(method, arg) if respond_to? method end end end </code></pre> <h3>use search.rb</h3> <pre><code>q = "foo:(hello world) bar:(-{bad things}) email:something@email.tld another:weird characters +=2{-52!%#^ final:end"; s = Search.new(q) s.exec </code></pre> <h3>output</h3> <pre><code>foo has (hello world) bar has (-{bad things}) email has something@email.tld another has weird characters +=2{-52!%#^ final has end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload