输入:
rstan::stan_model
预期输出:
+---------+
|full_name|
+---------+
| $raja|
| #raja|
| .raja|
我的代码仅从第一条记录中删除了+---------+
|full_name|
+---------+
| raja|
| raja|
| raja|
val df2 = df1.select("full_name").withColumn("full_name",regexp_replace(col("full_name"), "^[$_]", ""))
。如何获得预期的输出?
答案 0 :(得分:0)
这是因为在正则表达式中,您仅搜索字符串开头的$
符号。尝试添加要替换的其他符号,如下所示:
val df2 = df1.withColumn("full_name",regexp_replace(col("full_name"), "^[$#\\._]", ""))
获得预期的输出:
+---------+
|full_name|
+---------+
| raja|
| raja|
| raja|
+---------+