Create a gist now

Instantly share code, notes, and snippets.

Embed
Unicode
(ns api.unicode
(:refer-clojure :exclude [count seq subs]))
(def reg (if (exists? js/window)
(js* "/(\\P{Mark}\\p{Mark}*)/u")
(.build (js/require "xregexp") "(\\P{Mark}\\p{Mark}*)" "A")))
(defn seq [txt] (when txt (map first (re-seq reg txt))))
(defn count [txt] (cljs.core/count (seq txt)))
(defn subs
([txt from] (subs txt from (count txt)))
([txt from to]
(apply str (take (- to from) (drop from (seq txt))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment