Regex Lookahead character restrictions? -
i trying learn things regex. starting off trying hide matches 9 digit number, such ssn, let through 9 digit numbers have word "order" or "routing number" seems strings have same length work. there way around without creating multiple lines? thanks!
(?<!(order:\s|routing\snumber:\s)) (?!000|666)([0-6]\d\d|7[01256]\d|73[0123]|77[012]) ([-]?) ([1-9]{2}) \3 ([1-9]{4}) (?!([\w&/%"-]))
for blocking out ssns, 1 seems work ^(?!000)(?!666)(?!9)\d{3}([- ]?)(?!00)\d{2}\1(?!0000)\d{4}$
want not block out 9 digit numbers have words "order" or "routing number" in front of them.
many regular expression engines require lookbehind of fixed length, , refuse execute variable-length lookbehind; if case yours, should see warning. if you're not seeing warning, chances problem regexp doesn't wok way think does.
however, possible lookbehinds match text prefer count lookbehind, discard/ignore when you're inspecting captures or match object.
Comments
Post a Comment