Public Vars

Back

re-matches (clj)

(source)

function

(re-matches re s)
Returns the match, if any, of string to pattern, using java.util.regex.Matcher.matches(). Uses re-groups to return the groups.

Examples

originrose/cortex
(ns cortex.util-test
  (:refer-clojure :exclude [defonce])
  (:require
    #?(:cljs [cljs.test :refer-macros [deftest is testing]]
       :clj [clojure.test :refer [deftest is testing]])
    [clojure.core.matrix :as m]
    [clojure.string :as str]
    [cortex.util :refer :all]))

(deftest fmt-string-regex-test
  (is (= (rest (re-matches fmt-string-regex "%3$2s"))
         ["3" "2s"]))
  (is (= (rest (re-matches fmt-string-regex "%(,.2f"))
         [nil "(,.2f"]))
  (is (= (map rest (re-seq fmt-string-regex "%1$tm %1$te,%1$tY"))
         [["1" "tm"]
          ["1" "te"]
          ["1" "tY"]]))
  (is (= (map rest (re-seq fmt-string-regex "Format %1$s as %1$.2f using the %%.2f formatter%n."))
         [["1" "s"]
          ["1" ".2f"]
          [nil "%"]
          [nil "n"]])))
originrose/cortex
(ns cortex.optimise.util-test
  (:refer-clojure :exclude [defonce])
  (:require [cortex.optimise.util :refer :all]
            [clojure.core.matrix :as m]
            [clojure.test :refer :all]))

(deftest fmt-string-regex-test
  (is (= (rest (re-matches fmt-string-regex "%3$2s"))
         ["3" "2s"]))
  (is (= (rest (re-matches fmt-string-regex "%(,.2f"))
         [nil "(,.2f"]))
  (is (= (map rest (re-seq fmt-string-regex "%1$tm %1$te,%1$tY"))
         [["1" "tm"]
          ["1" "te"]
          ["1" "tY"]]))
  (is (= (map rest (re-seq fmt-string-regex "Format %1$s as %1$.2f using the %%.2f formatter%n."))
         [["1" "s"]
          ["1" ".2f"]
          [nil "%"]
          [nil "n"]])))
Quantisan/docker-clojure
(ns docker-clojure.config
  (:require [clojure.spec.alpha :as s]
            [clojure.string :as str]
            [docker-clojure.core :as-alias core]))

(s/def ::docker-image-name (s/and ::non-blank-string
                                  #(re-matches #"[-\w]+(?::[-\w.]+)?" %)))
(s/def ::docker-tag (s/and ::non-blank-string
                           #(re-matches #"[-\w.]+" %)))
(s/def ::base-image-tag ::docker-image-name)

(s/def ::build-tool (s/or ::specific-tool ::non-blank-string
                          ::all-tools #(= ::core/all %)))
(s/def ::build-tool-version
  (s/nilable (s/and ::non-blank-string #(re-matches #"[\d\.]+" %))))
(s/def ::build-tools (s/map-of ::build-tool ::build-tool-version))
tanders/clojure2minizinc
(ns clojure2minizinc.core-test
  (:refer-clojure :exclude [> >= <= < = == != -> + - * / mod assert concat min max 
                            int float set and or not nth
                            string?
                            count range sort])
  ;; Doc for clojure.test: http://clojure.github.io/clojure/clojure.test-api.html
  (:require [clojure.core :as core]
            [clojure.test :refer :all]
            [clojure2minizinc.core :refer :all]
            [clojure.java.shell :as shell]
            [clojure.spec :as spec]))


(def email-regex #"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$")
(spec/def ::email-type (spec/and core/string? #(re-matches email-regex %)))
SevereOverfl0w/vim-replant
(do
  (clojure.core/create-ns 'replant.locate)
  (clojure.core/in-ns 'replant.locate)
  (clojure.core/require '[clojure.core :refer :all])

  (some identity
        (for [potential-dev-ns ['dev 'user 'boot.user]
              potential-fn ['resume 'go 'start]]
          (do
            (try (require potential-dev-ns)
                 (catch Exception _))
            (some-> (find-ns potential-dev-ns)
                    (ns-resolve potential-fn)
                    (str)
                    (->> (re-matches #"#'(.*)")
                         (second))
                    symbol)))))