@Austin_Robinson_(GX): Hey @Vinicius_Machado_Mansur! Thanks for reaching out.
What is your backend (Pandas / Spark / SQLAlchemy)? The regex is passed from GX through to the backend-specific regex parser, and so support for those flags will be dependent on whether that engine can parse them.
@Vinicius_Machado_Mansur: I’m using Pandas. I wanted to make the test case insensitive (/i)
@Austin_Robinson_(GX): Hey @Vinicius_Machado_Mansur! Thanks for that context.
Pandas utilizes the python re
module to parse regex. You can see that documentation here. From their docs:
(?aiLmsux)
(One or more letters from the set 'a', 'i', 'L', 'm', 's', 'u', 'x'.) The group matches the empty string; the letters set the corresponding flags: re.A (ASCII-only matching), re.I (ignore case), re.L (locale dependent), re.M (multi-line), re.S (dot matches all), re.U (Unicode matching), and re.X (verbose), for the entire regular expression. (The flags are described in Module Contents.) This is useful if you wish to include the flags as part of the regular expression, instead of passing a flag argument to the re.compile() function. Flags should be used first in the expression string.
GX doesn’t currently support passing a flags
argument, so the above would be the best way forward here.
@Vinicius_Machado_Mansur: OK, thank you @Austin_Robinson_(GX)!
The “inline” notation worked well:
validator.expect_column_values_to_match_regex(
column="zipcode",
regex="(?i)^[ABCEGHJ-NPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][ -]?\d[ABCEGHJ-NPRSTV-Z]\d$"