[![在此处输入图像描述][1]][1]我想将子字符串 src="/slm/attachment/63338424306/Note.jpg"
替换为子字符串 jira/rally/images
在 Java 中使用正则表达式。
下面是获取包含子字符串src="/slm/attachment/63338424306/Note.jpg"的字符串列表的查询
criteria.add(Restrictions.like("comment", "%<img%"));
criteria.setMaxResults(1);
List<Comments> list = criteria.list();
如何使用正则表达式进行替换?请在这里帮助我。
假设 xxxxxxxxsrc="/slm/attachment/63338424306/Note.jpgxxxxxxxx
是替换后的字符串,我期待 xxxxxxxxsrc="jira/rally/images/Note.jpgxxxxxxxx
没有。 63338424306
可以是任意随机编号。
图像名称和格式“Note.jpg”可以更改,即“abc.png”等。
基本上,我想将 /slm/attachment/63338424306/
替换为 jira/rally/images
感谢大家的回答。我已经更新了一点问题,请帮助我。
最佳答案
yourString.replaceAll("src=\"/slm/attachment", "src=\"/jira/rally/images");
关于java - 我们如何使用Java中的正则表达式将下面的 'x'子字符串替换为 'y'子字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55016812/