本文整理了Java中org.apache.commons.lang3.StringUtils.removeFirst()
方法的一些代码示例,展示了StringUtils.removeFirst()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringUtils.removeFirst()
方法的具体详情如下:
包路径:org.apache.commons.lang3.StringUtils
类名称:StringUtils
方法名:removeFirst
[英]Removes the first substring of the text string that matches the given regular expression.
This method is a null safe equivalent to:
A null reference passed to this method is a no-op.
The Pattern#DOTALL option is NOT automatically added. To use the DOTALL option prepend "(?s)"
to the regex. DOTALL is also known as single-line mode in Perl.
StringUtils.removeFirst(null, *) = null
StringUtils.removeFirst("any", (String) null) = "any"
StringUtils.removeFirst("any", "") = "any"
StringUtils.removeFirst("any", ".*") = ""
StringUtils.removeFirst("any", ".+") = ""
StringUtils.removeFirst("abc", ".?") = "bc"
StringUtils.removeFirst("A<__>\n<__>B", "<.*>") = "A\n<__>B"
StringUtils.removeFirst("A<__>\n<__>B", "(?s)<.*>") = "AB"
StringUtils.removeFirst("ABCabc123", "[a-z]") = "ABCbc123"
StringUtils.removeFirst("ABCabc123abc", "[a-z]+") = "ABC123abc"
[中]删除与给定正则表达式匹配的文本字符串的第一个子字符串。
此方法是空安全的等效方法:
*文本。replaceFirst(regex,StringUtils.EMPTY)
*模式。编译(regex)。匹配器(文本)。replaceFirst(StringUtils.EMPTY)
传递给此方法的null引用是no-op。
Pattern#DOTALL选项不会自动添加。使用DOTALL选项将"(?s)"
前置到正则表达式。DOTALL在Perl中也称为单线模式。
StringUtils.removeFirst(null, *) = null
StringUtils.removeFirst("any", (String) null) = "any"
StringUtils.removeFirst("any", "") = "any"
StringUtils.removeFirst("any", ".*") = ""
StringUtils.removeFirst("any", ".+") = ""
StringUtils.removeFirst("abc", ".?") = "bc"
StringUtils.removeFirst("A<__>\n<__>B", "<.*>") = "A\n<__>B"
StringUtils.removeFirst("A<__>\n<__>B", "(?s)<.*>") = "AB"
StringUtils.removeFirst("ABCabc123", "[a-z]") = "ABCbc123"
StringUtils.removeFirst("ABCabc123abc", "[a-z]+") = "ABC123abc"
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testRemoveFirst_StringString() {
assertNull(StringUtils.removeFirst(null, ""));
assertEquals("any", StringUtils.removeFirst("any", null));
assertEquals("any", StringUtils.removeFirst("any", ""));
assertEquals("", StringUtils.removeFirst("any", ".*"));
assertEquals("", StringUtils.removeFirst("any", ".+"));
assertEquals("bc", StringUtils.removeFirst("abc", ".?"));
assertEquals("A\n<__>B", StringUtils.removeFirst("A<__>\n<__>B", "<.*>"));
assertEquals("AB", StringUtils.removeFirst("A<__>\n<__>B", "(?s)<.*>"));
assertEquals("ABCbc123", StringUtils.removeFirst("ABCabc123", "[a-z]"));
assertEquals("ABC123abc", StringUtils.removeFirst("ABCabc123abc", "[a-z]+"));
try {
StringUtils.removeFirst("any", "{badRegexSyntax}");
fail("StringUtils.removeFirst expecting PatternSyntaxException");
} catch (final PatternSyntaxException ex) {
// empty
}
}
代码示例来源:origin: virjar/vscrawler
@Override
protected String handle(String input, String second) {
return StringUtils.removeFirst(input, second);
}
代码示例来源:origin: pietermartin/sqlg
private PartitionTree(
String schemaAndName,
String schema,
String name,
String partitionType,
String partitionExpression1,
String partitionExpression2,
String fromToIn) {
this.schemaAndName = schemaAndName;
this.schema = schema;
this.name = StringUtils.removeEnd(StringUtils.removeFirst(name, "\""), "\"");
this.partitionExpression1 = partitionExpression1;
this.partitionExpression2 = partitionExpression2;
this.fromToIn = fromToIn;
if (partitionType == null) {
this.partitionType = PartitionType.NONE;
} else {
this.partitionType = PartitionType.fromPostgresPartStrat(partitionType);
}
}
代码示例来源:origin: org.umlg/sqlg-core
private PartitionTree(
String schemaAndName,
String schema,
String name,
String partitionType,
String partitionExpression1,
String partitionExpression2,
String fromToIn) {
this.schemaAndName = schemaAndName;
this.schema = schema;
this.name = StringUtils.removeEnd(StringUtils.removeFirst(name, "\""), "\"");
this.partitionExpression1 = partitionExpression1;
this.partitionExpression2 = partitionExpression2;
this.fromToIn = fromToIn;
if (partitionType == null) {
this.partitionType = PartitionType.NONE;
} else {
this.partitionType = PartitionType.fromPostgresPartStrat(partitionType);
}
}
代码示例来源:origin: zc-zh-001/ShadowSocks-Share
/**
* 图片解析
*/
protected ShadowSocksDetailsEntity parseImg(String imgURL) throws IOException, NotFoundException {
String str = StringUtils.removeFirst(imgURL, "data:image/png;base64,");
Map<DecodeHintType, Object> hints = new LinkedHashMap<>();
// 解码设置编码方式为:utf-8,
hints.put(DecodeHintType.CHARACTER_SET, StandardCharsets.UTF_8.name());
//优化精度
hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
//复杂模式,开启PURE_BARCODE模式
hints.put(DecodeHintType.PURE_BARCODE, Boolean.TRUE);
try (ByteArrayInputStream bis = new ByteArrayInputStream(Base64.decodeBase64(str))) {
BufferedImage image = ImageIO.read(bis);
Binarizer binarizer = new HybridBinarizer(new BufferedImageLuminanceSource(image));
BinaryBitmap binaryBitmap = new BinaryBitmap(binarizer);
Result res = new MultiFormatReader().decode(binaryBitmap, hints);
return parseLink(res.toString());
}
}
代码示例来源:origin: com.github.binarywang/weixin-java-pay
String fileNotFoundMsg = "证书文件【" + this.getKeyPath() + "】不存在,请核实!";
if (this.getKeyPath().startsWith(prefix)) {
String path = StringUtils.removeFirst(this.getKeyPath(), prefix);
if (!path.startsWith("/")) {
path = "/" + path;
代码示例来源:origin: binarywang/WxJava
String fileNotFoundMsg = "证书文件【" + this.getKeyPath() + "】不存在,请核实!";
if (this.getKeyPath().startsWith(prefix)) {
String path = StringUtils.removeFirst(this.getKeyPath(), prefix);
if (!path.startsWith("/")) {
path = "/" + path;
内容来源于网络,如有侵权,请联系作者删除!