问题标签 [apache-stringutils]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
256 浏览

java - substringBetween() 尝试提取时返回 null ..

我正在构建一个小型 Java 应用程序来获取五个 Wikipedia 页面并在 html 源代码中查找子字符串。我正在使用库 org.apache.commons.lang3.StringUtils。然而,维基百科的文章可能很大,而且 StringUtils 似乎有一个限制:

为什么控制台null打印trimmedHtml?输出应该(几乎)和 for 一样大html。字符串输出或参数是否有最大长度substringBetween()

0 投票
1 回答
829 浏览

java - StringUtils.countMatches() 不适用于制表符字符

我正在验证一个包含以下内容的 csv 文件:

TEST;F;12345;0X4321 - 1234 DUMMYTEXT;0X4321 - 1234 TESTTEXT

到目前为止,这些值由“;”分隔 这个方法就像一个魅力:

作为一个更改的要求,现在我必须将制表位作为列分隔符处理,而文本可以包含空格:

TEST F 12345 0x4321 - 1234 DUMMYTEXT 0x4321 - 1234 TESTTEXT

我更改了以下行:

问题: StringUtils.countMatches(line, "\\t") 找不到任何事件(返回 0)。我不想这样做:

因为我很迷信,这会对性能造成重大影响(csv 文件不小)。你知道更好的方法吗?

0 投票
1 回答
179 浏览

java - 为什么 StringUtils 会返回不正确的子字符串匹配数?

我正在使用 apache commons 库中的 StringUtils 来检查 html 页面源代码中子字符串的匹配数。

我已经使用 webdriver 命令转换了页面源:

我用来查找匹配项的代码是:

当我手动执行检查时,我得到 2 个匹配项。这是我所期待的。

但是当我在自动化的 Selenium 脚本中使用上述代码时,我得到了 5 个结果。

关于我哪里出错的任何想法/想法?

谢谢你。

0 投票
1 回答
252 浏览

java - How does the offset parameter works in the function abbreviate(String str,int offset,int maxWidth), in package org.apache.commons.lang.StringUtils

I am presently working with the apache commons lang package, StringUtils class. I found there are two abbreviation methods: abbreviate(String str,int maxwidth) and abbreviate(String str,int offset,int maxwidth) it is absolutely ok with the first one. But when come to the second one it is little bit confusing and I really need the clarification. I saw two cases of the abbreviate(String str,int offset,int maxwidth) function. those are:-

returns "abcdefg...", and the second:

also returns "abcdefg...".

After seeing this I am really in confution how exactly the offset parameter works??

0 投票
2 回答
563 浏览

java - Java 在字符串 URL 中搜索子字符串 URL

我有几个网址:

我正在使用 Apache stringutls 来查看 'b' 中是否存在 'a' 但我认为正斜杠无法进行比较。是否有更简单/更好的方法来查找“b”中是否存在“a”,包括正斜杠?谢谢。

0 投票
1 回答
1071 浏览

ant - 如何让 Ant 在文件末尾“咀嚼”换行符?

我正在使用 Ant LoadFile任务从存储库根目录中的文件中读取版本。

由于用于创建和编辑它的工具,版本文件以换行符结尾。Ant 正在读取并使用该换行符作为属性值的一部分。当我使用该值作为文件或输出的替换时,这让我很困惑。

有没有办法在加载后或作为加载文件任务的一部分将其从属性中删除?


我说的是这种Chomp


VERSION文件实际上只包含版本号和换行符(行号是我的说明)。

0 投票
1 回答
1222 浏览

maven - 从 net.sourceforge.dynamicreports 添加排除 apache.commons.lang3

我想在我的项目中添加一个依赖项来使用动态报告,我发现了这个:

但是当我将它添加到我的时pom.xml,我得到了这个错误:The method isNoneBlank(String) is undefined for the type StringUtils错误StringUtils.isNoneBlank(...)

我认为这是 lang3 版本的冲突

如何添加排除项commons.lang3

0 投票
1 回答
565 浏览

java - 阿帕奇公共语言。Stringutils.splitByWholeseparator 做奇怪的事情。

0 投票
1 回答
2704 浏览

java - StringUtils.capitalize() 的反函数

图书馆StringUtils.capitalize()里有方便的方法。apache-commons-lang但是我找不到它的成对逆方法,它会使单词中的第一个字母变成小写。这种方法存在吗?

0 投票
0 回答
418 浏览

java - StringUtils 并发异常

我收到以下错误:

用于跑步StringUtils.join

StringUtils文档提到:#ThreadSafe#

怎么了?该代码位于实现 Callable 的 java 类中。

我的完整代码:

这是调用可调用的方法: