title: How to allow specific values in my string
body: <p>I want to replace space with <code>"|"</code> and i want only numbers and alphabets and star(*) in the sting</p>
  
  <p>And i have tried <code>str_replace()</code> funtion but it replace the space with | , but i want to validate </p>
  
  <pre><code>echo $text= str_replace(' ','|', "This is some $123 Money");
  </code></pre>
  
  <p>output </p>
  
  <pre><code>This|is|some|$123|Money
  </code></pre>
  
  <p>what i expect is </p>
  
  <pre><code>This|is|some|123|Money
  </code></pre>
  
  <p>I don't want any other special characters in my output</p>
  
  <p>Any Suggestions</p>
  
  <p>Thanks in Advance</p>