Extract Card Numbers
Extract Iranian bank card numbers from text with advanced features including performance optimizations, fuzzy matching, and comprehensive validation.Features
- TypeScript Function Overloads: Type-safe extraction based on options
- Performance Optimized: Handles small to large texts (1MB+) efficiently
- Multi-Format Support: Persian, Arabic digits and various separators
- Fuzzy Matching: Partially masked card numbers like
6037-****-8909-5443 - Context Extraction: Surrounding text analysis
- Position Tracking: Exact location of matches in text
- Duplicate Removal: Automatic deduplication
- Iranian Bank Validation: Integration with Iranian bank validation
Installation
Basic Usage
TypeScript Function Overloads
The function provides type-safe overloads based on your options:Advanced Options
Performance Optimization
Fuzzy Matching
Context Extraction
Multi-Format Support
The function automatically handles various formats:Options Reference
| Option | Type | Default | Description |
|---|---|---|---|
checkValidation | boolean | true | Enable Luhn algorithm validation |
detectBankNumber | boolean | false | Detect Iranian bank names |
filterValidCardNumbers | boolean | true | Filter out invalid cards when validation enabled |
maxResults | number | unlimited | Maximum number of cards to extract |
optimizeForLargeText | boolean | auto-detect | Enable performance optimizations |
enableFuzzyMatching | boolean | false | Support partially masked card numbers |
includeContext | boolean | false | Include surrounding text context |
contextLength | number | 20 | Number of characters for context |
Result Types
ExtractCardNumberBase
ExtractCardNumberWithValidation
ExtractCardNumberWithBank
ExtractCardNumberComplete
Performance Characteristics
- Small texts (< 1KB): < 1ms processing time
- Medium texts (1KB-10KB): < 10ms processing time
- Large texts (10KB-100KB): < 50ms with optimization
- Huge texts (> 100KB): < 200ms with chunking strategy
Iranian Bank Integration
Automatically detects Iranian banks:- بانک ملی (Bank Melli)
- بانک کشاورزی (Bank Keshavarzi)
- بانک تجارت (Bank Tejarat)
- بانک سپه (Bank Sepah)
- بانک ملت (Bank Mellat)
- And 30+ other Iranian banks
Error Handling
The function handles various edge cases gracefully:Migration from v1.x
The v2.0 enhancement maintains 100% backward compatibility:Browser Support
Works in all modern browsers and Node.js environments:- Chrome 60+
- Firefox 55+
- Safari 12+
- Edge 79+
- Node.js 14+
Related Functions
verifyCardNumber- Validate individual card numbersgetBankNameFromCardNumber- Get bank name from card number
