suchen

Heim  >  Fragen und Antworten  >  Hauptteil

javascript – Verwenden Sie PHP, um den vom Rich-Text-Editor erstellten Code zu verarbeiten. Ersetzen Sie den href des Links durch title="fish link" zu bbb.com

Zum Beispiel:

ersetzt durch

Bitte finden Sie eine Lösung.

習慣沉默習慣沉默2827 Tage vor679

Antworte allen(2)Ich werde antworten

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-24 11:32:47

    preg_replace 正则表达式的搜索和替换

    Antwort
    0
  • 漂亮男人

    漂亮男人2017-05-24 11:32:47

    使用preg_replace, 写了个简单的例子:

    
    $b = '
    <a href="http://tool.chinaz.com/" title="fish link">df</a>
    <a href="http://tool.chinaz.com/" title="no match">df</a>
    <a href="http://tool.chinaz.com/" title="fish link">df</a>
    ';
    
    var_dump(preg_replace('/<a.*title="fish link">/', '<a href="http://bbb.com" title="fish link">', $b));

    output:

    string(157) "
    <a href="http://bbb.com" title="fish link">df</a>
    <a href="http://tool.chinaz.com/" title="no match">df</a>
    <a href="http://bbb.com" title="fish link">df</a>
    "

    Antwort
    0
  • StornierenAntwort