简体   繁体   中英

substrings find and replace in large string using java

I have list of articles in html.In every article i have multiple image tags like added below

<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" /> 

Problem Statement: I want to replace urls of image present in src, srcset ie http://localhost/myfolder/my-content/uploads/2016/11/Quick-start.jpg to some other url. whats the best approach to do that. I am thinking about functional programming in java

是的,这可以使用 java 来完成。但是如果您使用像 jquery 这样的 java 脚本框架进行操作,这将很容易。

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM