Skip to content

Commit

Permalink
Merge pull request #19 from luckman212/3-digit-codes
Browse files Browse the repository at this point in the history
quick fix to find 3-digit codes e.g. Zocdoc
  • Loading branch information
squatto authored May 26, 2021
2 parents b520270 + 2e25c39 commit 40c9f2c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion find-messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
and message.text is not null
and length(message.text) > 0
and (
message.text glob '*[0-9][0-9][0-9][0-9]*'
message.text glob '*[0-9][0-9][0-9]*'
or message.text glob '*[0-9][0-9][0-9][0-9]*'
or message.text glob '*[0-9][0-9][0-9][0-9][0-9]*'
or message.text glob '*[0-9][0-9][0-9][0-9][0-9][0-9]*'
or message.text glob '*[0-9][0-9][0-9]-[0-9][0-9][0-9]*'
Expand Down Expand Up @@ -124,6 +125,11 @@
// "Your verification code is: 1234, use it to log in"
// "Here is your authorization code:9384"
$code = $matches[2];
} elseif (preg_match('/(code|is):?\s*(\d{3,8})($|\s|\R|\t|\b|\.|,)/i', $text, $matches)) {
// "code" OR "is" followed by an optional ":" + optional whitespace, then 3-8 consecutive digits
// examples:
// "Please enter code 548 on Zocdoc."
$code = $matches[2];
} elseif (preg_match('/(^|code:|is:|\b)\s*(\d{3})-(\d{3})($|\s|\R|\t|\b|\.|,)/', $text, $matches)) {
// line beginning OR "code:" OR "is:" OR word boundary, optional whitespace, 3 consecutive digits, a hyphen, then 3 consecutive digits
// but NOT a phone number (###-###-####)
Expand Down

0 comments on commit 40c9f2c

Please sign in to comment.