Public Vars

Back

re-seq (clj)

(source)

function

(re-seq re s)
Returns a lazy sequence of successive matches of pattern in string, using java.util.regex.Matcher.find(), each such match processed with re-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"]])))
hraberg/deuce
(ns deuce.emacs.fileio
  (:use [deuce.emacs-lisp :only (defun defvar) :as el])
  (:require [clojure.core :as c]
            [clojure.string :as s]
            [clojure.java.io :as io]
            [deuce.emacs.buffer :as buffer]
            [deuce.emacs.data :as data]
            [deuce.emacs.eval :as eval]
            [deuce.emacs.editfns :as editfns])
  (:import [java.nio.file Files LinkOption
            NoSuchFileException]
           [deuce.emacs.data Buffer BufferText])
  (:refer-clojure :exclude []))

  If `/~' appears, all of FILENAME through that `/' is discarded.
  If `//' appears, everything up to and including the first of
  those `/' is discarded."
  (let [filename (-> filename
                     (s/replace #".+(~/.+)" "$1")
                     (s/replace #".+/(/.+)" "$1"))
        vars (re-seq #"\$(\w+|\{.+\})" filename)]
    (reduce #(s/replace %1 (first %2) (System/getenv (second %2))) filename vars)))
typedclojure/typedclojure
(ns ^:no-doc typed.ann.clojure
  "Type annotations for the base Clojure distribution."
  #?(:cljs (:require-macros [typed.ann-macros.clojure :as macros]))
  (:require [clojure.core :as cc]
            [typed.clojure :as t]
            #?(:clj [typed.ann-macros.clojure :as macros])
            #?(:clj typed.ann.clojure.jvm) ;; jvm annotations
            #?(:clj clojure.core.typed))
  #?(:clj
     (:import (clojure.lang PersistentHashSet PersistentList
                            APersistentMap #_IPersistentCollection
                            #_ITransientSet
                            IRef)
              (java.util Comparator Collection))))

cc/re-find (t/IFn #?(:clj [java.util.regex.Matcher :-> (t/U nil t/Str (t/Vec (t/Option t/Str)))])
                  [t/Regex t/Str :-> (t/U nil t/Str (t/Vec (t/Option t/Str)))])
cc/re-seq [t/Regex t/Str :-> (t/ASeq (t/U nil t/Str (t/Vec (t/Option t/Str))))]