I have a dataset where I need to extract the alias in a domain style format: domain\alias where the alias is after the backslash. The backslash seems to be treated as an escape character despite a few attempts at getting it to be treated as a character. I first tested my regex pattern using a known non-escape character, the forward slash with success. I then tried the same pattern with the backslash and then several permutations with methods familiar to me to get regex to treat the backslash as a character and not as an escape character without success. What do you do to get this regex pattern to work with a backslash in spark?
Regex Pattern Verification
select regexp_extract('domain/alias', '/(.*)') as test --Results: alias Works with forward slash.
Permutations and Results
select regexp_extract('domain\alias', '\(.*)') as test --Results: domainalias Removes the backslash for some reason
select regexp_extract('domain\alias', '"""\"""(.*)') as test --Results: empty string
select regexp_extract('domain\alias', '"""\\"""(.*)') as test --Results: empty string
select regexp_extract('domain\alias', '\\(.*)') as test --Results: Error in SQL statement: NullPointerException:
select regexp_extract('domain\alias', '\\\(.*)') as test --Results: Error in SQL statement: NullPointerException: