Much more efficient line-splitting
This commit is contained in:
parent
0a5ef01169
commit
ff259fe683
10
vcarded.scm
10
vcarded.scm
|
@ -32,14 +32,10 @@
|
||||||
(remove string-null? (string-split string "\r\n")))
|
(remove string-null? (string-split string "\r\n")))
|
||||||
|
|
||||||
|
|
||||||
;; Create irregx-format regex for matching an unescaped character.
|
;; Splits a line into a cons of the property-string and value-string.
|
||||||
(define (regex-unescaped-char char-string)
|
;; … basically splits the string along the first unescaped colon (:).
|
||||||
`(: (neg-look-behind "\\") ,char-string))
|
|
||||||
|
|
||||||
|
|
||||||
;; Splits a line into a list of key/value pairs.
|
|
||||||
(define (split-vcard-line line)
|
(define (split-vcard-line line)
|
||||||
(let [(split (irregex-split (regex-unescaped-char ":") line))]
|
(let [(split (irregex-extract "(\\\\:|[^:])*" line))]
|
||||||
(if (>= (length split) 2)
|
(if (>= (length split) 2)
|
||||||
(cons
|
(cons
|
||||||
(car split)
|
(car split)
|
||||||
|
|
Ŝarĝante…
Reference in New Issue