|
@@ -0,0 +1,430 @@
|
|
|
+package cn.com.qmth.examcloud.bridge.modules.cloudmarking.controller;
|
|
|
+
|
|
|
+import cn.com.qmth.examcloud.bridge.modules.cloudmarking.bean.Block;
|
|
|
+import cn.com.qmth.examcloud.bridge.modules.cloudmarking.bean.Section;
|
|
|
+import cn.com.qmth.examcloud.bridge.modules.cloudmarking.bean.Sections;
|
|
|
+import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
+import cn.com.qmth.examcloud.commons.util.*;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.ExamRecordCloudService;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.ExamRecordQuestionsCloudService;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.OeExamStudentCloudService;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.bean.ToBeMarkExamRecordBean;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.bean.ToBeMarkExamStudentBean;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.bean.ToBeMarkSubjectiveAnswerBean;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.request.GetToBeMarkExamRecordReq;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.request.GetToBeMarkExamStudentReq;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.response.GetToBeMarkExamRecordResp;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.response.GetToBeMarkExamStudentResp;
|
|
|
+import cn.com.qmth.examcloud.web.config.SystemProperties;
|
|
|
+import com.google.common.collect.Maps;
|
|
|
+import com.mysql.cj.util.StringUtils;
|
|
|
+import org.apache.commons.io.FileUtils;
|
|
|
+import org.apache.http.HttpStatus;
|
|
|
+import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
+import org.apache.http.client.methods.HttpGet;
|
|
|
+import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
+import org.apache.http.util.EntityUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.nio.charset.Charset;
|
|
|
+import java.util.*;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description 云阅卷客户端接口
|
|
|
+ * 错误码范围(102001 至 101999)
|
|
|
+ * @Author lideyin
|
|
|
+ * @Date 2019/11/20 14:49
|
|
|
+ * @Version 1.0
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("cmcClient")
|
|
|
+public class CloudMarkingClientController {
|
|
|
+ @Autowired
|
|
|
+ ExamRecordQuestionsCloudService examRecordQuestionsCloudService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ SystemProperties systemConfig;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ExamRecordCloudService examRecordCloudService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ OeExamStudentCloudService oeExamStudentCloudService;
|
|
|
+
|
|
|
+ Logger logger = LoggerFactory.getLogger(CloudMarkingClientController.class);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量生成主观题答案,以压缩文件方式返回
|
|
|
+ */
|
|
|
+ @GetMapping(value = "batchGetAnswer/{examId}")
|
|
|
+ public ResponseEntity<?> batchGetSubjectiveAnswer(@PathVariable Long examId) {
|
|
|
+ if (null == examId) {
|
|
|
+ throw new StatusException("101001", "考试批次id不允许为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ GetToBeMarkExamStudentReq req = new GetToBeMarkExamStudentReq();
|
|
|
+ req.setExamId(examId);
|
|
|
+ //获取考试批次下所有考生
|
|
|
+ GetToBeMarkExamStudentResp toBeMarkExamStudentResp = oeExamStudentCloudService.getToBeMarkExamStudent(req);
|
|
|
+ List<ToBeMarkExamStudentBean> examStudentList = toBeMarkExamStudentResp.getExamStudentList();
|
|
|
+ if (examStudentList.isEmpty()) {
|
|
|
+ throw new StatusException("101002", "该考试批次下无待阅考生数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (logger.isDebugEnabled()) {
|
|
|
+// logger.debug("[BATCH_GET_ANSWER-" + examId + "],获取考试批次下所有考生:" + JsonUtil.toJson(examStudentList));
|
|
|
+ logger.debug("[001.BATCH_GET_ANSWER-" + examId + "],获取考试批次下所有考生数量:" + examStudentList.size());
|
|
|
+ }
|
|
|
+
|
|
|
+ for (ToBeMarkExamStudentBean stu : examStudentList) {
|
|
|
+ GetToBeMarkExamRecordReq getExamRecordReq = new GetToBeMarkExamRecordReq();
|
|
|
+ getExamRecordReq.setExamStudentIdList(Arrays.asList(stu.getExamStudentId()));
|
|
|
+
|
|
|
+ GetToBeMarkExamRecordResp getExamRecordResp = examRecordCloudService.getToBeMarkExamRecord(getExamRecordReq);
|
|
|
+
|
|
|
+ saveDataToLocal(getExamRecordResp,examId);
|
|
|
+ }
|
|
|
+
|
|
|
+ //最终文件的生成目录
|
|
|
+ final String tempAnswerDir = systemConfig.getTempDataDir() + "/exam-" + examId;
|
|
|
+ String zipPath = tempAnswerDir + "-" + System.currentTimeMillis() + ".zip";
|
|
|
+ File zipFile = new File(zipPath);
|
|
|
+ ZipUtil.zip(new File(tempAnswerDir), zipFile);
|
|
|
+
|
|
|
+ byte[] bytes = IOUtil.toByteArray(zipFile);
|
|
|
+
|
|
|
+ String downLoadFileName = "exam-" + examId + ".zip";
|
|
|
+ ResponseEntity<byte[]> responseEntity = ResponseEntity.ok().
|
|
|
+ header("Content-Disposition", "attachment; filename=" + downLoadFileName).
|
|
|
+ contentType(MediaType.APPLICATION_OCTET_STREAM).body(bytes);
|
|
|
+
|
|
|
+ clearTempAnswerFile(tempAnswerDir);
|
|
|
+ return responseEntity;
|
|
|
+
|
|
|
+
|
|
|
+// return ResponseEntity.ok().body("数据生成完毕.");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 清空临时目录中的文件
|
|
|
+ *
|
|
|
+ * @param tempAnswerDir
|
|
|
+ */
|
|
|
+ private void clearTempAnswerFile(String tempAnswerDir) {
|
|
|
+ File t1 = new File(tempAnswerDir);
|
|
|
+ for (File f : t1.listFiles()) {
|
|
|
+ FileUtils.deleteQuietly(f);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void saveDataToLocal(GetToBeMarkExamRecordResp resp, Long examId) {
|
|
|
+
|
|
|
+ if (!resp.getToBeMarkExamRecordBeanList().isEmpty()) {
|
|
|
+
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ String COL_SEPARATOR = "\t";//列分隔符
|
|
|
+ String LINE_BREAK = "\r\n";//换行
|
|
|
+ //循环待审阅的考试记录
|
|
|
+ for (ToBeMarkExamRecordBean rb : resp.getToBeMarkExamRecordBeanList()) {
|
|
|
+ //构建文本文件串
|
|
|
+ sb.append(rb.getStudentName()).append(COL_SEPARATOR)
|
|
|
+ .append(rb.getStudentCode()).append(COL_SEPARATOR)
|
|
|
+ .append(rb.getCourseName()).append(COL_SEPARATOR)
|
|
|
+ .append(rb.getCourseCode()).append(COL_SEPARATOR)
|
|
|
+ .append(rb.getPaperType()).append(COL_SEPARATOR)
|
|
|
+ .append(rb.getExamRecordDataId()).append(LINE_BREAK);
|
|
|
+
|
|
|
+ //答案临时存放目录
|
|
|
+ final String tempAnswerDir =
|
|
|
+ systemConfig.getTempDataDir() + "/exam-" + rb.getExamId() + "/" + rb.getCourseCode() + "-" + rb.getPaperType();
|
|
|
+
|
|
|
+ if (logger.isDebugEnabled()) {
|
|
|
+ logger.debug("[BATCH_GET_ANSWER-" + examId + "],临时文件目录:" + JsonUtil.toJson(tempAnswerDir));
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> resultMapList = new ArrayList<>();
|
|
|
+
|
|
|
+ //循环主观题答案
|
|
|
+ for (ToBeMarkSubjectiveAnswerBean sab : rb.getSubjectiveAnswerList()) {
|
|
|
+ Map<String, Object> resultMap = Maps.newHashMap();
|
|
|
+ //构建基本信息
|
|
|
+ resultMap.put("mainNumber", sab.getMainNumber());//大题号
|
|
|
+ resultMap.put("subNumber", sab.getOrder());//小题号
|
|
|
+
|
|
|
+ //构建题干
|
|
|
+ resultMap.put("body",getBodyOrAnswer(sab.getBody()));
|
|
|
+
|
|
|
+ //构建标准答案
|
|
|
+ resultMap.put("answer",getBodyOrAnswer(sab.getAnswer()));
|
|
|
+
|
|
|
+ //构建学生作答
|
|
|
+ resultMap.put("studentAnswer", buildStudentAnswerMap(sab));
|
|
|
+
|
|
|
+ resultMapList.add(resultMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ //将考生结果保存至临时文件
|
|
|
+ String answerJson = JsonUtil.toJson(resultMapList);
|
|
|
+ String jsonFilePath = tempAnswerDir + "/" + rb.getExamRecordDataId() + ".json";
|
|
|
+
|
|
|
+ if (logger.isDebugEnabled()) {
|
|
|
+ logger.debug("[BATCH_GET_ANSWER-" + examId + "],最终作答结果路径:jsonFilePath=" + jsonFilePath);
|
|
|
+ }
|
|
|
+ if (logger.isDebugEnabled()) {
|
|
|
+ logger.debug("[BATCH_GET_ANSWER-" + examId + "],最终作答结果:answerJson=" + answerJson);
|
|
|
+ }
|
|
|
+
|
|
|
+ IOUtil.toFile(answerJson.getBytes(Charset.forName("UTF-8")), jsonFilePath);
|
|
|
+ }
|
|
|
+
|
|
|
+ final String tempAnswerDir = systemConfig.getTempDataDir() + "/exam-" + examId;
|
|
|
+ if (!StringUtils.isNullOrEmpty(sb.toString())) {
|
|
|
+ String txtFilePath = tempAnswerDir + "/examStudent.txt";
|
|
|
+ IOUtil.toFile(sb.toString().getBytes(Charset.forName("UTF-8")), txtFilePath);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if (logger.isDebugEnabled()) {
|
|
|
+ logger.debug("[006.BATCH_GET_ANSWER-" + examId + "],enter saveDataToLocal-----GetToBeMarkExamRecordResp 空数据");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, Object> buildStudentAnswerMap(ToBeMarkSubjectiveAnswerBean sab) {
|
|
|
+ Map<String, Object> studentAnswerMap = Maps.newHashMap();
|
|
|
+
|
|
|
+ List<Map<String, Object>> sectionMapList = new ArrayList<>();
|
|
|
+ Map<String, Object> sectionMap = Maps.newHashMap();
|
|
|
+ List<Map<String, Object>> blockMapList = new ArrayList<>();
|
|
|
+
|
|
|
+ //校验答案格式,校验成功才追加至集合,否则不追加
|
|
|
+ if (validateAnswer(sab.getRealAnswerType(), sab.getStudentAnswer())) {
|
|
|
+ //图片文件特殊处理
|
|
|
+ if (!StringUtils.isNullOrEmpty(sab.getStudentAnswer()) &&
|
|
|
+ "image".equals(sab.getRealAnswerType())) {
|
|
|
+ if (sab.getStudentAnswer().indexOf("|") > -1) {
|
|
|
+ String[] imgAnswers = sab.getStudentAnswer().split("\\|");
|
|
|
+ for (int i = 0; i < imgAnswers.length; i++) {
|
|
|
+ Map<String, Object> blockMap = Maps.newHashMap();
|
|
|
+ blockMap.put("type", sab.getRealAnswerType());
|
|
|
+ blockMap.put("value", transformedAnswer(sab.getRealAnswerType(), imgAnswers[i]));
|
|
|
+
|
|
|
+ //又拍云图片的宽*高
|
|
|
+ String imgWH = RegExpUtil.find(imgAnswers[i], "(\\d+)x(\\d+)");
|
|
|
+ if (!StringUtils.isNullOrEmpty(imgWH)) {
|
|
|
+ Map<String, Object> paramMap = new HashMap<>();
|
|
|
+ paramMap.put("width", Integer.valueOf(imgWH.split("x")[0]));
|
|
|
+ paramMap.put("height", Integer.valueOf(imgWH.split("x")[1]));
|
|
|
+ blockMap.put("param", paramMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ blockMapList.add(blockMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Map<String, Object> blockMap = Maps.newHashMap();
|
|
|
+ blockMap.put("type", sab.getRealAnswerType());
|
|
|
+ blockMap.put("value", transformedAnswer(sab.getRealAnswerType(), sab.getStudentAnswer()));
|
|
|
+ blockMapList.add(blockMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ sectionMap.put("blocks", blockMapList);
|
|
|
+ sectionMapList.add(sectionMap);
|
|
|
+
|
|
|
+ studentAnswerMap.put("sections", sectionMapList);
|
|
|
+ return studentAnswerMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String transformedAnswer(String answerType, String studentAnswer) {
|
|
|
+ if ("image".equals(answerType)) {
|
|
|
+ String regExp = "(ftp|https?)\\:\\/\\/([\\w\\_\\-]+)\\.([\\w\\-]+[\\.]?)*[\\w]+\\.[a-zA-Z]{2,10}(.*)\\.(png|jpg|gif|jpeg)";
|
|
|
+ return RegExpUtil.find(studentAnswer, regExp);
|
|
|
+ }
|
|
|
+ return studentAnswer;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验答案格式是否正确
|
|
|
+ *
|
|
|
+ * @param realAnswerType
|
|
|
+ * @param studentAnswer
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private boolean validateAnswer(String realAnswerType, String studentAnswer) {
|
|
|
+ if (StringUtils.isNullOrEmpty(studentAnswer)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ String regExp;
|
|
|
+ switch (realAnswerType) {
|
|
|
+ case "image":
|
|
|
+ //图片必须包含.png|jpg|gif|jpeg
|
|
|
+ regExp = "^(ftp|https?)\\:\\/\\/([\\w\\_\\-]+)\\.([\\w\\-]+[\\.]?)*[\\w]+\\.[a-zA-Z]{2,10}(.*)\\.(png|jpg|gif|jpeg).*$";
|
|
|
+ return studentAnswer.matches(regExp);
|
|
|
+ case "audio":
|
|
|
+ //音频必须包含.mp3
|
|
|
+ regExp = "^(ftp|https?)\\:\\/\\/([\\w\\_\\-]+)\\.([\\w\\-]+[\\.]?)*[\\w]+\\.[a-zA-Z]{2,10}(.*)\\.(mp3)";
|
|
|
+ return studentAnswer.matches(regExp);
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取格式化后后的题干或标准答案
|
|
|
+ * @param str
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Sections getBodyOrAnswer(String str) {
|
|
|
+ Sections body = new Sections();
|
|
|
+ List<Section> sections = new ArrayList<>();
|
|
|
+ // 得到小题题干或者答案行数
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isBlank(str)) {
|
|
|
+ return body;
|
|
|
+ }
|
|
|
+ String[] questionRowStrings = str.split("</p>");
|
|
|
+ for (int i = 0; i < questionRowStrings.length; i++) {
|
|
|
+ List<Block> blocks = disposeQuestionBodyOrOption(questionRowStrings[i]);
|
|
|
+ if (blocks != null && blocks.size() > 0) {
|
|
|
+ Section section = new Section();
|
|
|
+ // 将小题题干拆分为Block集合
|
|
|
+ section.setBlocks(blocks);
|
|
|
+ sections.add(section);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ body.setSections(sections);
|
|
|
+ return body;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Block> disposeQuestionBodyOrOption(String questionRow) {
|
|
|
+ List<Block> blocks = new ArrayList<>();
|
|
|
+ // 去掉每行里面的<p>,<span>,</span>标签
|
|
|
+ questionRow = questionRow.replaceAll("<p>", "").replaceAll("</p>", "").replaceAll("<span>", "")
|
|
|
+ .replaceAll("</span>", "").replaceAll("</a>", "");
|
|
|
+ String[] questionRowStrings = questionRow.split("<|/>|>");
|
|
|
+ for (int i = 0; i < questionRowStrings.length; i++) {
|
|
|
+ Block block = new Block();
|
|
|
+ String rowStr = questionRowStrings[i];
|
|
|
+ // 判断是否有图片
|
|
|
+ if (rowStr.startsWith("img")) {
|
|
|
+ rowStr = "<" + rowStr + ">";
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
+ // 需要继续做截取,取到Parma
|
|
|
+ block.setType("image");
|
|
|
+ // 获取图片的路径
|
|
|
+ List<String> strSrcList = getImg(rowStr, "src");
|
|
|
+ if (strSrcList.size() > 0) {
|
|
|
+ String strSrc = strSrcList.get(0).replaceAll("src=\"", "").replaceAll("\"", "");
|
|
|
+ block.setValue(strSrc);
|
|
|
+ }
|
|
|
+ // 获取图片的高度
|
|
|
+ List<String> strHeightList = getImg(rowStr, "height");
|
|
|
+ if (strHeightList.size() > 0) {
|
|
|
+ String strHeight = strHeightList.get(0).replaceAll("height=\"", "").replaceAll("\"", "");
|
|
|
+ param.put("height", strHeight);
|
|
|
+ }
|
|
|
+ // 获取图片的宽度
|
|
|
+ List<String> strWidthList = getImg(rowStr, "width");
|
|
|
+ if (strHeightList.size() > 0) {
|
|
|
+ String strWidth = strWidthList.get(0).replaceAll("width=\"", "").replaceAll("\"", "");
|
|
|
+ param.put("width", strWidth);
|
|
|
+ }
|
|
|
+ block.setParam(param);
|
|
|
+ blocks.add(block);
|
|
|
+ } else if (rowStr.startsWith("a") && rowStr.contains("id") && rowStr.contains("name")) { // 处理音频
|
|
|
+ rowStr = "<" + rowStr + ">";
|
|
|
+ block.setPlayTime(1);
|
|
|
+ block.setType("audio");
|
|
|
+ block.setValue(this.getAttrValue(rowStr, "id"));
|
|
|
+ blocks.add(block);
|
|
|
+ } else {
|
|
|
+ block.setType("text");
|
|
|
+ rowStr = rowStr.replace(" ", "");// 消除空格
|
|
|
+ rowStr = rowStr.replace(""", "\"");// 将"转换成\"
|
|
|
+ rowStr = rowStr.replace("<", "<");// 将<转换成<
|
|
|
+ rowStr = rowStr.replace(">", ">");// 将>转换成>
|
|
|
+ rowStr = rowStr.replace("&", "&");// 将&转换成&
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isNotBlank(rowStr)) {
|
|
|
+ block.setValue(rowStr);
|
|
|
+ blocks.add(block);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return blocks;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取图片里面的路径,长度,宽度
|
|
|
+ */
|
|
|
+ private List<String> getImg(String s, String str) {
|
|
|
+ String regex;
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ regex = str + "=\"(.*?)\"";
|
|
|
+ Pattern pa = Pattern.compile(regex, Pattern.DOTALL);
|
|
|
+ Matcher ma = pa.matcher(s);
|
|
|
+ while (ma.find()) {
|
|
|
+ list.add(ma.group());
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getAttrValue(String questionStr, String attrName) {
|
|
|
+ Pattern aPattern = Pattern.compile("a.*");
|
|
|
+ Matcher aMatcher = aPattern.matcher(questionStr);
|
|
|
+
|
|
|
+ if (aMatcher.find()) {
|
|
|
+ String idRegex = attrName + "=\".*?\"";
|
|
|
+ Pattern idPattern = Pattern.compile(idRegex);
|
|
|
+ Matcher idMatcher = idPattern.matcher(aMatcher.group());
|
|
|
+ if (idMatcher.find()) {
|
|
|
+ return idMatcher.group()
|
|
|
+ .replaceAll(attrName + "=\"", "")
|
|
|
+ .replaceAll("\"", "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验字符串和正则表达式是否匹配
|
|
|
+ *
|
|
|
+ * @param regExp
|
|
|
+ * @param input
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private boolean isRegExpMatch(String regExp, String input) {
|
|
|
+ Pattern pattern = Pattern.compile(regExp);
|
|
|
+ Matcher matcher = pattern.matcher(input);
|
|
|
+ return matcher.matches();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String regExp = "^(ftp|https?)\\:\\/\\/([\\w\\_\\-]+)\\.([\\w\\-]+[\\.]?)*[\\w]+\\.[a-zA-Z]{2,10}(.*)\\.(png|jpg|gif|jpeg)(\\s|\\S)*$";
|
|
|
+ String regExp1 = "(ftp|https?)\\:\\/\\/([\\w\\_\\-]+)\\.([\\w\\-]+[\\.]?)*[\\w]+\\.[a-zA-Z]{2,10}(.*)\\.(png|jpg|gif|jpeg)";
|
|
|
+ String regExp2 = "(\\d+)x(\\d+)";
|
|
|
+ String input = "https://ecs-test-static.qmth.com.cn/oe-answer-file/3/7/20/3_7_20_15748449608356000.jpeg!/both/200x200";
|
|
|
+ Pattern pattern = Pattern.compile(regExp);
|
|
|
+ Matcher matcher = pattern.matcher(input);
|
|
|
+//
|
|
|
+ System.out.println(matcher.matches());
|
|
|
+ System.out.println(matcher.group());
|
|
|
+ System.out.println(RegExpUtil.find(input, regExp1));
|
|
|
+ System.out.println(RegExpUtil.find(input, regExp2));
|
|
|
+
|
|
|
+ }
|
|
|
+}
|