Nokogiri replace tag values

前端 未结 2 1190
情书的邮戳
情书的邮戳 2021-01-21 23:55

How to replace \"foo\" to \"bar\" ?

From

foo1

foo2foo4foo5

foo6

2条回答
  •  一整个雨季
    2021-01-22 00:09

    I could do

    nokogiri_doc.css('p').each { |p| p.inner_html = p.inner_html.gsub(/\n/, "
    ") }

    To replace all ocurrences of \n inside p tag to br tags

提交回复
热议问题