【发布时间】:2015-01-08 11:29:40
【问题描述】:
我正在尝试引入 html 验证错误并删除错误的第一部分以仅显示实际的文本部分,但遇到了问题。我想删除文本后的“ValidationError line 23 col 40:'”和最后一个“'”。
package htmlvalidator;
import java.util.ArrayList;
public class ErrorCleanup {
public static void main(String[] args) {
//Saving the raw errors to an array list
ArrayList<String> list = new ArrayList<String>();
//Add the text to the first spot
list.add("ValidationError line 23 col 40:'Bad value ius-cors for attribute name on element >meta: Keyword ius-cors is not registered.'");
//Show what is in the list
System.out.println("The error message is: " + list);
}
}
【问题讨论】:
-
我不太确定您的错误会是什么样子。但是,接受每行第一个
:之后发生的所有内容是否有效?如果是这样,您可以使用String类的split方法。