problem of searching strings that contain characters like [ with preg_replace
<p>I'm trying to take a random string and use it in preg_replace. When $random takes a value that contains [ character php returns "Compilation failed: missing terminating ] for character class at offset" error. Not just ] there are other characters cause error. </p>

<p>How can I solve this problem?</p>

<pre><code>$random='asd[qwe';

preg_replace("/$random/", "replaced value", $text, 1);
</code></pre>

<p>Any ideas? </p>
