1 package com.foxinmy.weixin4j.util;
2
3 import java.util.regex.Matcher;
4 import java.util.regex.Pattern;
5
6
7
8
9
10
11
12
13
14
15 public final class RegexUtil {
16
17
18
19 private static final Pattern FILENAME_RGX = Pattern
20 .compile("(?<=filename=\").*?(?=\")");
21
22
23
24
25
26
27
28 public static String regexFileNameFromContentDispositionHeader(
29 String contentDisposition) {
30 if (StringUtil.isBlank(contentDisposition)) {
31 return null;
32 }
33 Matcher filenameMatcher = FILENAME_RGX.matcher(contentDisposition);
34 return filenameMatcher.find() ? filenameMatcher.group() : null;
35 }
36 }