以下代码,
String string = "<xml attributes>some xml code</xml>"
+ "<xml attributes>some xml code</xml>"
+ "<xml attributes>some xml code</xml>"
+ "<xml attributes>some xml code</xml>";
String[] stringArray = string.split("<xml");
for ( String i : stringArray) {
System.out.println(i);
}
版画
attributes>some xml code</xml>
attributes>some xml code</xml>
attributes>some xml code</xml>
attributes>some xml code</xml>
但是我想在每个数组索引中保留<xml字,这样输出将是,
<xml attributes>some xml code</xml>
<xml attributes>some xml code</xml>
<xml attributes>some xml code</xml>
<xml attributes>some xml code</xml>
参考方案
稍微更改代码以使用正向后看。
String[] stringArray = string.split("(?<=</xml>)");
O / P:
<xml attributes>some xml code</xml>
<xml attributes>some xml code</xml>
<xml attributes>some xml code</xml>
<xml attributes>some xml code</xml>
休眠映射<键,设置<值>> - java我有以下表格:@Entity @Table(name = "events") Event --id --name @Entity @Table(name = "state") State --id --name @Entity @Table(name = "action") Action --id …
在集成测试阶段执行Maven模块 - java我想启动一个同级Maven 3模块,该模块在我的一个Maven模块中充当应用程序服务器,以对系统运行集成测试。我的maven项目看起来与此类似:父模块模块A模块B现在,我想在Maven的集成前测试阶段中启动“模块A”,然后运行模块B中包含的所有集成测试。我设法在模块B中运行了集成测试,但是没有找到“光滑”的方法在集成前测试阶段启动模块B。最佳做法是什么?使用…
当我所有的都是T时,如何返回Interface <T>的实例? - java我有一个界面:public interface ILoginResult<T> { public T get(); } 我有一个LoginPage对象:public class LoginPage<T> { ... public ILoginResult<T> login(...) { ... } } 我也有一些登录页面对…
在Maven构建之前如何运行课程? - java为什么以下原因导致构建失败?我创建了一个应该在maven开始执行构建之前运行的类。 <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.5.…
Java Applet的URLConnection与PHP无效 - java我已经研究了Oracle文档和示例,但仍然无法正常工作。我有一个Java Applet,它只是尝试使用URLConnection和OutputStreamWriter通过POST将文本字段发送到PHP脚本。 Java方面似乎工作正常,没有引发异常,但是PHP在我的页面上未显示任何输出。我是PHP新手,因此请耐心等待。这是相关的Java部分: try { UR…