作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
输入文件:
key1=1
key2=start(a
b
c=
d)end
key3=d=e=f
somekey=start(123)end
morekey=start(1
2)end
key=jj
输出
key1 -> 1
key2 -> a
b
c=
d
key3 -> d=e=f
somekey -> 123
morekey -> 1
2
key -> jj
请求:在java中尝试。不能使用 java.util.Properties,正则表达式可以,但不是首选,更喜欢 StringUtils.substringBetween,但正则表达式可以。如何遍历多行并保留换行符。以下显然不适用于多行。打算尝试正则表达式,但前提是不可能有更优雅的方式。
String[] str = line.split("=", 2);
StringUtils.substringBetween(line,startString,endString));
最佳答案
你的意思是这样的吗:
String str = "key1=1\n"
+ "key2=start(a\n"
+ "b\n"
+ "c=\n"
+ "d)end\n"
+ "key3=d=e=f\n"
+ "somekey=start(123)end\n"
+ "morekey=start(1\n"
+ "2)end\n"
+ "key=jj";
System.out.println(str.replaceAll("start\\(|\\)end", "")
.replaceAll("(\\w{2})=", "$1\t-> ")
.replaceAll("(\n\\w)", "\t$1"));
关于java - 提取键/值对,值可以跨行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43945523/
1.) 我想查询,哪些fk_pathway id包含所有3个fk_link id(101,51,87)。在此示例中结果将是路径 ID 2 和路径 ID 3。 2.) 我想查询,哪些fk_pathway
我想将 2 列的网格 div 放置在与第 2 行 div 内联的位置(见图)。总行数是动态的。
我有一个 UL,在一个 div 中,我在其中设置了 DIV、UL 和 LI 的宽度。如果有的话,我想让溢出滚动,所以我将溢出设置为自动。但是,当 LI 太宽时,我似乎无法阻止 LI 跨线。这是我正在使
对于一个特殊的问题,我有一个看起来非常低效的解决方案。我有文本数据,由于各种原因,这些数据以随机间隔跨数据帧的行进行分解。然而,根据数据框中其他变量的独特组合,已知某些子集属于同一组。例如,请参阅演示
我是一名优秀的程序员,十分优秀!