我正在使用spark SQL,并尝试使用rlike
比较字符串,它可以正常工作,但是想了解如何忽略大小写。
此返回true
select "1 Week Ending Jan 14, 2018" rlike "^\\d+ Week Ending [a-z, A-Z]{3} \\d{2}, \\d{4}"
但是,此返回False,
select "1 Week Ending Jan 14, 2018" rlike "^\\d+ week ending [a-z, A-Z]{3} \\d{2}, \\d{4}"
答案 0 :(得分:0)
Spark使用标准的Scala regex库,因此您可以内嵌模式中的处理标记,例如,不区分大小写的(?i):
spark.sql("""select "1 Week Ending Jan 14, 2018" rlike "(?i)^\\d+ week ending [a-z, A-Z]{3} \\d{2}, \\d{4}"""").show()
+--------------------------------------------------------------------------------+
|1 Week Ending Jan 14, 2018 RLIKE (?i)^\d+ week ending [a-z, A-Z]{3} \d{2}, \d{4}|
+--------------------------------------------------------------------------------+
| true|
+--------------------------------------------------------------------------------+