forked from microsoft/presidio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUkNinoRecognizer.cs
More file actions
31 lines (28 loc) · 994 Bytes
/
UkNinoRecognizer.cs
File metadata and controls
31 lines (28 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
namespace ManagedCode.Presidio.Analyzer;
/// <summary>
/// Recognizes UK National Insurance numbers using Presidio's canonical regex and context.
/// </summary>
public sealed class UkNinoRecognizer(
IEnumerable<Pattern>? patterns = null,
IEnumerable<string>? context = null,
string supportedLanguage = "en",
string supportedEntity = "UK_NINO") : PatternRecognizer(
supportedEntity,
patterns ?? DefaultPatterns,
context: context ?? DefaultContext,
supportedLanguage: supportedLanguage)
{
private static readonly Pattern[] DefaultPatterns =
{
new(
"NINO (high)",
@"\b(?!bg|gb|nk|kn|nt|tn|zz|BG|GB|NK|KN|NT|TN|ZZ) ?([a-ceghj-pr-tw-zA-CEGHJ-PR-TW-Z]{1}[a-ceghj-npr-tw-zA-CEGHJ-NPR-TW-Z]{1}) ?([0-9]{2}) ?([0-9]{2}) ?([0-9]{2}) ?([a-dA-D]{1})\b",
1.0),
};
private static readonly string[] DefaultContext =
{
"national insurance",
"ni number",
"nino",
};
}