Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 如何在spark上应用正则表达式,以便在spark上仅提取数字_Regex_Apache Spark - Fatal编程技术网

Regex 如何在spark上应用正则表达式,以便在spark上仅提取数字

Regex 如何在spark上应用正则表达式,以便在spark上仅提取数字,regex,apache-spark,Regex,Apache Spark,我正在尝试在我的数据集上使用正则表达式。 我的问题是我想用空字母替换字母表 我尝试了以下代码 val test_reg = xmlData.withColumn("volume",regexp_replace($"trans_volume", "[^0-9]", "")) 但是,如果我的输入包含alpahabets以外的内容,那么它也将替换为空 lets say my input contains 34m89 it replaces as 3489 which is perfectl

我正在尝试在我的数据集上使用正则表达式。 我的问题是我想用空字母替换字母表

我尝试了以下代码

   val test_reg = xmlData.withColumn("volume",regexp_replace($"trans_volume", "[^0-9]", ""))
但是,如果我的输入包含alpahabets以外的内容,那么它也将替换为空

  lets say my input contains 34m89 it replaces as 3489 which is perfectly fine.
  but if my input contains 34.78 that is getting replaced as 3478 which actually should not happen. 
能帮我解决我的问题吗

val test_reg = xmlData.withColumn("volume",regexp_replace($"trans_volume", "[^0-9].", ""))
您可能应该在正则表达式中添加“[^0-9]”。