How do we strip all non-numeric characters from customer phone numbers using regular expressions?
regexp_replace() matches a regex pattern and replaces all occurrences with a replacement string.
Phone number standardization, removing special characters, and data masking for privacy compliance.
from pyspark.sql.functions import col, regexp_replace
df = df.withColumn("clean_phone", regexp_replace(col("phone"), "[^0-9]", ""))Practice typing production-grade PySpark code for Pattern Replacement with regexp_replace().