簡體   English   中英

子字符串使用java在大字符串中查找和替換

[英]substrings find and replace in large string using java

我有 html 中的文章列表。在每篇文章中,我都有多個圖像標簽,如下所示

<img alt="quick-start" class="alignnone size-full wp-image-16745" height="224" sizes="(max-width: 474px) 100vw, 474px" src="http://localhost/myfolder/my-content/uploads/2016/11/Quick-start.jpg" srcset="http://localhost/myfolder/my-content/uploads/2016/11/Quick-start.jpg 474w, http://localhost/myfolder/my-content/uploads/2016/11/Quick-start-300x142.jpg 300w" style="box-sizing: border-box; margin-top: 10px; margin-bottom: 10px;" width="474" /> 

問題陳述:我想將src, srcsethttp://localhost/myfolder/my-content/uploads/2016/11/Quick-start.jpg 中存在的圖像 url 替換為其他一些 url。 什么是最好的方法來做到這一點。 我正在考慮用 Java 進行函數式編程

是的,這可以使用 java 來完成。但是如果您使用像 jquery 這樣的 java 腳本框架進行操作,這將很容易。

$(".image2").attr("src","image1.jpg");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM