我解析日誌文件並嘗試匹配錯誤語句。我匹配的「錯誤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