| 170 | // ============================================================ |
| 171 | |
| 172 | function extractVerificationCode(text) { |
| 173 | // Pattern 1: Chinese format "代码为 370794" or "验证码...370794" |
| 174 | const matchCn = text.match(/(?:代码为|验证码[^0-9]*?)[\s::]*(\d{6})/); |
| 175 | if (matchCn) return matchCn[1]; |
| 176 | |
| 177 | // Pattern 2: English format "code is 370794" or "code: 370794" |
| 178 | const matchEn = text.match(/code[:\s]+is[:\s]+(\d{6})|code[:\s]+(\d{6})/i); |
| 179 | if (matchEn) return matchEn[1] || matchEn[2]; |
| 180 | |
| 181 | // Pattern 3: standalone 6-digit number (first occurrence) |
| 182 | const match6 = text.match(/\b(\d{6})\b/); |
| 183 | if (match6) return match6[1]; |
| 184 | |
| 185 | return null; |
| 186 | } |