-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextChecker.java
More file actions
27 lines (24 loc) · 804 Bytes
/
Copy pathTextChecker.java
File metadata and controls
27 lines (24 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class TextChecker extends StringCheckerBase {
int size = 0;
@Override
public boolean check(String data) {
Pattern pattern = Pattern.compile("\"(.*?(\\\\\")*)*(\")|'(.*?(\\\\')*)*(')");
Matcher matcher = pattern.matcher(data);
if (!matcher.find()) {
return false;
}
String matched = matcher.group(0);
if (data.startsWith(matched)) {
size = matched.length();
return (matched.endsWith("\"") || matched.endsWith("'")) &&
!(matched.endsWith("\\\"") || matched.endsWith("\\'"));
}
return false;
}
@Override
public String getText(String data) {
return data.substring(0, size);
}
}