How to split string at fixed numbers of character in clojure? -


i'm new in clojure. i'm learning splitting string in various ways. i'm taking here: https://clojuredocs.org/clojure.string/split there no example split string @ fixed number of character.

let string "hello welcome here". want split string after every 4th char, output (after split) should ["hell" "o ev" "eryo" "ne w" "elco" "me t" "o he" "re"]. note white space consider char.

can tell me, how can this? thanks.

you use re-seq:

user> (def s "hello welcome here") #'user/s  user> (re-seq #".{1,4}" s) ("hell" "o ev" "eryo" "ne w" "elco" "me t" "o he" "re") 

or partition string, treating seq:

user> (map (partial apply str) (partition-all 4 s)) ("hell" "o ev" "eryo" "ne w" "elco" "me t" "o he" "re") 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -