2015-10-19 58 views
1

正則表達式我有以下語句:如何解決警告字段名不匹配,斯卡拉

val summarizationList = Map(4 -> "Monthly", 3 -> "Weekly", 2 -> "Daily", 1 -> "Hourly") 

val Type: Int = summarizationList.find(_._2 == lastSummarizationDate._1._1).get._1 

val SummarizedDate = (lastSummarizedDate.toList.sortBy(_._2) ++ Map("End" -> end)).sliding(2) 
     .map(a => (a(0), a(1))).toList 

在過去的兩個語句正在逐漸「字段名稱不匹配正則表達式「^ [AZ] [ A-ZA-Z0-9] * $'「

如何解決以下警告?

+0

什麼是'lastSummarizationDate'和'lastSummarizedDate'? –

回答

1
scala> "Type".matches("^[a-z][A-Za-z0-9]*$") 
res0: Boolean = false 
scala> "SummarizedDate".matches("^[a-z][A-Za-z0-9]*$") 
res1: Boolean = false 
scala> "type".matches("^[a-z][A-Za-z0-9]*$") 
res2: Boolean = true 
scala> "summarizedDate".matches("^[a-z][A-Za-z0-9]*$") 
res3: Boolean = true 

您的變量名應該以小寫字母開頭。

+0

適合我 – sk1007