Regular expressions.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(ns foo.baz
  (:api dunaj)
  (:require [dunaj.regex :refer [split]]))

(canonical #"[a-zA-Z]*")
;;=> "[a-zA-Z]*"

(matches #"(a)(sdf)" "asdf")
;;=> ["asdf" "a" "sdf"]

;; must match entire input
(matches #"(a)(sdf)" "asdfX")
;;=> nil

;; parse-whole is different than matches
(seq (parse-whole #"(a)(sdf)" "asdfX"))
;;=> ("asdf" "a" "sdf")

;; parse replaces clojure.core/re-seq
(seq (parse #"(a)(sdf)" "asdffsadasdfdd"))
;;=> (["asdf" "a" "sdf"] ["asdf" "a" "sdf"])

(split #"a" "asdfaasdfasdf")
;;=> ("" "sdf" "" "sdf" "sdf")

(split #"a" "asdfaasdfasdf" 2)
;;=> ("" "sdfaasdfasdf")

Regex

Available since version 1.0 (view source)

not referred automatically

TYPE

A type for regular expressions. Supports ICanonical and can be used in dunaj.format/parse.

matches

Available since version 1.0 (alias of clojure.core/re-matches)

Usage:
  • (matches re s)

Type signature:
  • (java.util.regex.Pattern ⨯ ICharSequence) → Any

Returns the match, if any, of string s to pattern re, using host matcher.

quote+

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (quote+ s)

Type signature:
  • (String+) → String+

Returns literal quoted string for use in regex pattern.

quote-replacement

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (quote-replacement s)

Type signature:
  • (String+) → String+

Returns literal quoted string for use in regex based replacements, e.g. in dunaj.string/replace.

regex

Available since version 1.0 (alias of clojure.core/re-pattern)

not referred automatically

Usage:
  • (regex s)

Type signature:
  • ((U Regex String+)) → Regex

Returns an instance of host compiled regular expression pattern.

regex?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (regex? x)

Type signature: Predicate

Returns true if object x is an instance of Regex type, false otherwise.

split

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (split re coll)

  • (split re coll limit)

Type signatures:
  • ((U String+ Regex) ⨯ (Maybe IRed)) → []

  • ((U String+ Regex) ⨯ (Maybe IRed) ⨯ Integer+) → []

Returns collection of splitted coll according to regex re.