Created
June 8, 2018 20:28
-
-
Save galdolber/1568e767fe69f9439874cc20c755b80e to your computer and use it in GitHub Desktop.
Unicode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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