我目前正在收到rn
文字,其中换行符\r\n
- 应该是(很可能是压缩的结果)。
在php中,我想用<br/>
安全地替换它。
目前,我所拥有的是
str_replace("rn", "<br/>", text);
但如果输入像"corn"
这样的单词,那么这会失败。
任何使这项工作的方法?我希望它使用preg_replace()
但不确定。
编辑:文字示例为foo barrnbaz bop
答案 0 :(得分:0)
preg_replace()
是前往这里的方式。您可以使用字词边界def update(conn, %{"time_stamp_id" => time_stamp_id, "user_id" => user_id, "assing_card" => assing_card} = params) do
time_stamp = Repo.get!(TimeStamp, time_stamp_id) |> Repo.preload [:user, :card]
time_stamp = %{time_stamp | user_id: String.to_integer(user_id)}
if assing_card do
time_stamps = time_stamp.card
|> Repo.preload(:time_stamps)
|> Map.get(:time_stamps)# here I have list with time_stamps ... How to |> Repo.update_all(set: [user_id: String.to_integer(user_id)]) ?
...
,因此当它是单词的一部分时,它与\b
不匹配,例如。
rn