我解析日志文件并尝试匹配错误语句。我匹配的“错误CS”这一行的部分将应用于许多行,其中一些不重复。有没有一种方法我不能返回重复项。使用正则表达式的味道的Java ..正则表达式在模式匹配时返回唯一行
例如:我简单的regex返回
Class1.cs(16,27): error CS0117: 'string' does not contain a definition for 'empty'
Class1.cs(34,20): error CS0103: The name 'thiswworked' does not exist in the current context
Class1.cs(16,27): error CS0117: 'string' does not contain a definition for 'empty'
Class1.cs(34,20): error CS0103: The name 'thiswworked' does not exist in the current context
想它返回:
Class1.cs(16,27): error CS0117: 'string' does not contain a definition for 'empty'
Class1.cs(34,20): error CS0103: The name 'thiswworked' does not exist in the current context
您使用哪种语言,Java或C#? – NullUserException 2010-09-22 16:08:22
参见:http://stackoverflow.com/questions/1863957/how-do-i-convert-an-array-of-strings-to-a-array-of-unique-values – kennytm 2010-09-22 16:11:55
根据结构的错误日志文件,您可能会丢弃正则表达式中的重复项。但是我建议你在比赛结束后这么做,比如Kenny在他的链接 – NullUserException 2010-09-22 16:14:39