Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require that SSNs be neither preceded nor followed by digits #4

Closed
waldoj opened this issue Jun 22, 2014 · 2 comments
Closed

Require that SSNs be neither preceded nor followed by digits #4

waldoj opened this issue Jun 22, 2014 · 2 comments
Assignees

Comments

@waldoj
Copy link
Member

waldoj commented Jun 22, 2014

Virtually any 10-plus-digit number is going to be matched, in part, by our regular expression. We really only want to match 9 digit numbers that are not preceded by or followed by digits. I've tried this:

(?:\D)(?!666|000|9\d{2})\d{3}(-?)(?!00)\d{2}\1(?!0{4})(?:\D)

but that also matches the preceding and following characters, returning results like A123-45-6789,. (The ?: ensures that the group isn't stored in memory by regex, but they're still being returned as part of the result.) Figure out how to require the presence of \D before and after, but not return them.

@waldoj
Copy link
Member Author

waldoj commented Jun 22, 2014

I think we can address this in Ruby with \K. Instead of beginning and ending the regex with (?:\D), we'd use (\D\K), which means not to keep that portion. Unfortunately, BBEdit 10 (which I'm using to test this regex against the corpus of documents) doesn't support \K, so I can't say for sure that it'll work.

@waldoj
Copy link
Member Author

waldoj commented Jun 22, 2014

D'oh—JRuby is based on Ruby 1.9.3. So \K, which requires Ruby 2, won't be supported. I'll need to come up with another method.

waldoj added a commit that referenced this issue Jun 22, 2014
@waldoj waldoj closed this as completed in a045c06 Jun 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant