![JAR search and dependency download from the Maven repository](/logo.png)
cn.ocoop.framework.common.util.FullTextUtils Maven / Gradle / Ivy
package cn.ocoop.framework.common.util;
import org.apache.commons.lang3.StringUtils;
import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class FullTextUtils {
public static Pattern imageTagPattern = Pattern.compile("(?i)()");
public static String convertBase64Image(String fullText, Function srcConvertor) {
if (StringUtils.isBlank(fullText)) return fullText;
Matcher matcher = imageTagPattern.matcher(fullText);
while (matcher.find()) {
fullText = matcher.replaceFirst(matcher.group(1) + srcConvertor.apply(matcher.group(2)) + matcher.group(3));
matcher.reset(fullText);
}
return fullText;
}
public static void main(String[] args) {
String str = "![](data:image/png;base64,sdf)
![](http://xxxx)
![](data:image/png;base64,sdf)
![](data:image/png;base64,sdf)
";
System.out.println(convertBase64Image(str, src -> {
System.out.println(src);
return "=====" + src;
}));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy