I understand \P{C} represents "invisible control characters and unused code points" https://www.regular-expressions.info/unicode.html
When I do this, (in a databricks notebook) it works fine:
%sql
SELECT regexp_replace('abcd', '\\P{C}', 'x')
But the following fails (both %python and %scala):
%python
s = "SELECT regexp_replace('abcd', '\\P{C}', 'x')"
display(spark.sql(s))
java.util.regex.PatternSyntaxException: Illegal repetition near index 0
P{C}
^
The SQL command also works fine in HIVE. I also tried escaping the curly braces as suggested here, but no use.
Is there anything else I am missing? Thanks.