rocknbil - 4:39 pm on Aug 19, 2010 (gmt 0)
I don't think you're going to be able to do that. The regexp must match the data, not the other way around, and you're asking to insert a character where there isn't one in the string, and it really can be anywhere. You could preprocess the input so it's like this, and do a long series of "or's":
where field = 'a-bcdef' or
field = 'ab-cdef' or
field = 'abc-def' ....
but that would be extremely unwieldy. You should probably re-think your front end, like
<p>Enter your product code:</p>
<input type="text" name="code-prefix" id="code-prefix">
<input type="text" name="code-suffix" id="code-suffix"></p>
Then you can do
$term = $_POST['code-prefix'] . '-' . $term = $_POST['code-sufffix'];
.... where field='$term';
This would be faster, more efficient, and less error prone anyway.