title: How to parse user search string for Postgresql query?
body: <p>i created a search engine on my site using full text search in Postegresql.
  i added a searchbox in my PHP page in which users can write strings like these:</p>
  
  <pre><code>word1 +word2
  word1+word2
  word1    -word2
   word1-word2
  word1 word2
  word1  word2
  </code></pre>
  
  <p>how to convert them to the following strings?</p>
  
  <pre><code>word1&amp;word2
  word1&amp;word2
  word1&amp;!word2
  word1&amp;!word2
  word1|word2
  word1|word2
  </code></pre>
  
  <p>i tried several solutions but none works with all cases.
  The last one i tried is the following:</p>
  
  <pre><code>    $user_query_string = trim($_GET['search']);
      $final_query_string = str_replace(array('+', ' ', '-'), array('&amp;','|', '&amp;!'), $user_query_string);
  </code></pre>