无关风月
2024-11-12 3818974122e7b80e0fe04fd5709a853bac831caa
xinquan-modules/xinquan-system/src/main/java/com/xinquan/system/controller/ContentSettingController.java
@@ -10,10 +10,13 @@
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
 * <p>
@@ -40,10 +43,10 @@
    public R<String> getCourseList(@RequestParam(value = "contentType", required = true) int contentType) {
        ContentSetting one = contentSettingService.lambdaQuery().eq(ContentSetting::getContentType, contentType).one();
        if (one!=null){
            return R.ok(one.getContent());
        }else{
            return R.ok();
        }
    }
    @PostMapping("/saveOrupdateContent")
@@ -67,5 +70,27 @@
        return R.ok();
    }
    public static void main(String[] args) {
        // 示例 HTML 字符串
        String htmlString = "<img src=\"https://xqgwzh.obs.cn-south-1.myhuaweicloud.com/17313899095390cf6c36b6172b7143579920e0dfb816a_0fd6cbede59403085e39fa106a528eb8f0a734f32528a68832340f7d68939d33.png\"></img>";
        // 定义正则表达式来提取 src 属性的值
        String regex = "<img[^>]+src=\"([^\"]+)\"";
        // 编译正则表达式
        Pattern pattern = Pattern.compile(regex);
        // 创建 Matcher 对象
        Matcher matcher = pattern.matcher(htmlString);
        // 查找匹配项并输出 src 属性值
        if (matcher.find()) {
            String imgSrc = matcher.group(1);  // 获取 src 属性值
            System.out.println("Extracted image source: " + imgSrc);
        } else {
            System.out.println("No image source found.");
        }
    }
}