summaryrefslogtreecommitdiff
path: root/ADSBDecoder/ADSBRegEx.swift
diff options
context:
space:
mode:
Diffstat (limited to 'ADSBDecoder/ADSBRegEx.swift')
-rw-r--r--ADSBDecoder/ADSBRegEx.swift54
1 files changed, 53 insertions, 1 deletions
diff --git a/ADSBDecoder/ADSBRegEx.swift b/ADSBDecoder/ADSBRegEx.swift
index e9ebe17..2841467 100644
--- a/ADSBDecoder/ADSBRegEx.swift
+++ b/ADSBDecoder/ADSBRegEx.swift
@@ -7,7 +7,7 @@
import Foundation
import RegexBuilder
-
+/*
let matchADSBLong = Regex {
Anchor.startOfLine
"*"
@@ -20,8 +20,35 @@ let matchADSBLong = Regex {
,count:28)
";"
+}*/
+class MatchADSBLong {
+ let matchADSBLong = Regex {
+ Anchor.startOfLine
+ "*"
+
+ Repeat(
+ CharacterClass(
+ ("a"..."f"),
+ ("0"..."9")
+ )
+ ,count:28)
+
+ ";"
+ }
+
+ func prefixMatch(_ line: String) -> Regex<Regex<Substring>.RegexOutput>.Match? {
+ do {
+ if let match = try matchADSBLong.prefixMatch(in: line) {
+ return match
+ }
+ } catch {
+ return nil
+ }
+ return nil
+ }
}
+/*
let matchADSBShort = Regex {
Anchor.startOfLine
"*"
@@ -32,4 +59,29 @@ let matchADSBShort = Regex {
)
,count:14)
";"
+}*/
+
+class MatchADSBShort {
+ let matchADSBShort = Regex {
+ Anchor.startOfLine
+ "*"
+ Repeat(
+ CharacterClass(
+ ("a"..."f"),
+ ("0"..."9")
+ )
+ ,count:14)
+ ";"
+ }
+
+ func prefixMatch(_ line: String) -> Regex<Regex<Substring>.RegexOutput>.Match? {
+ do {
+ if let match = try matchADSBShort.prefixMatch(in: line) {
+ return match
+ }
+ } catch {
+ return nil
+ }
+ return nil
+ }
}