我有一個足夠簡單的問題。在我的單元測試中,我將預期與實際輸出作爲字符串值進行比較。現在,字符串的一部分是隨機生成的唯一ID,這會導致測試每次都失敗。有沒有一種方法可以指定我的測試只匹配部分字符串中兩點之間的實際和忽略文本。像函數 -在Scala模式匹配過程中排除部分字符串
def isMatch(expected : String, actual : String , ignoreFrom : String , ignoreTo : String)
而且,因爲這是模式匹配的候選人,可能有人點我的模式匹配/正則表達式傻瓜樣的教程?
訪問這個鏈接將是有益的給你[鏈接1](HTTP://scala-programming-language.1934581.n4.nabble。 com/Pattern-matching-on-strings-td1947939.html)[link2](http://johlrogge.wordpress.com/2008/10/06/scala-nugget-pattern-matching-a nd-lists /) – Engineer
ignoreFrom是String還是Int? –