I trying to use rlike() to the money [whether it has dollar sign( $) , comma ( ,) , decimal sign(.) and numbers before and after the decimal sign also there can be a negative sign before / after the $ sign) Below is the regex expression i came up with - ^$?-?[0-9],?[0-9].?[0-9]*$ its can able tp find the match, if i try to test in https://regex101.com/
from pyspark.sql import SparkSession
from pyspark.sql.functions import *
df= df.unionAll(cdf.withColumn("ErrorMessage", lit("Invalid Amount Recovered"))\
.filter(~ col("AmountRecovered").rlike('^\$?\-?[0-9]*\,?[0-9]*\.?[0-9]*$'))).distinct()
display(df)
Also i tried replacing ~ with == False like this-
df= df.unionAll(cdf.withColumn("ErrorMessage", lit("Invalid Amount Recovered"))\
.filter( col("AmountRecovered").rlike('^\$?\-?[0-9]*\,?[0-9]*\.?[0-9]*$')==False)).distinct()
It is not working either.