帮助,我需要从!输入中替换一个类!与preg_replace。
我的代码是:
$v = '
<div class="inputbox">
<input type="text" name="inputbox" class="inputbox" autocomplete="off" style="box-sizing: border-box;">
<input type="text" name="f_name" id="f_name" value="" class="inputbox open based">
<input type="text" name="f_name" id="f_name" value="" class="inputbox label" style="box-sizing: border-box;">
</div>
';
我需要得到:
$v_complete = '
<div class="inputbox">
<input type="text" name="inputbox" class="form-control" autocomplete="off" style="box-sizing: border-box;">
<input type="text" name="f_name" id="f_name" value="" class="form-control open based">
<input type="text" name="f_name" id="f_name" value="" class="label form-control" style="box-sizing: border-box;">
</div>
';
日Thnx!
答案 0 :(得分:0)
$v_complete = preg_replace('#(input.*class="[^"]*)inputbox([\s"])#', '$1form-control$2', $v);