php-preg替换为空格和换行符


php preg replace with spaces and new line breaks

我有一个文本(在带有空格和制表符的文件中)

 <tr>
<th width="219" rowspan="2">dsf</th>
<th width="60" rowspan="2">dsfsdf</th>
<th width="135" colspan="2">dsfdsf</th>
  </tr>

和preg替换搜索

"!  <tr>
    <th width='"219'" rowspan='"2'">dsf</th>
    <th width='"60'" rowspan='"2'">dsfsdf</th>
    <th width='"135'" colspan='"2'">dsfdsf</th>
  </tr>!is",

这不是我的正则表达式,但客户说它以前有效,经过一些研究,我发现空间或换行符有问题。如果我试着只找到一个字符串,那就成功了。我正在打领带,没有任何帮助。也许有人可以帮我

查找空白时只需使用's+。这是一条既便宜又简单的出路。

<tr>'s+<th width='"219'" rowspan='"2'">dsf</th>'s+<th width='"60'" rowspan='"2'">dsfsdf</th>'s+<th width='"135'" colspan='"2'">dsfdsf</th>'s+</tr>

有关示例,请参阅此regex101链接。