Public Vars

Back

re-pattern (clj)

(source)

function

(re-pattern s)
Returns an instance of java.util.regex.Pattern, for use, e.g. in re-matcher.

Examples

hraberg/deuce
(ns deuce.emacs.dired
  (:use [deuce.emacs-lisp :only (defun defvar)])
  (:require [clojure.core :as c]
            [clojure.java.io :as io]
            [deuce.emacs-lisp.cons :as cons])
  (:import [java.io File])
  (:refer-clojure :exclude []))

(defun directory-files (directory &optional full match nosort)
  "Return a list of names of files in DIRECTORY.
  There are three optional arguments:
  If FULL is non-nil, return absolute file names.  Otherwise return names
   that are relative to the specified directory.
  If MATCH is non-nil, mention only file names that match the regexp MATCH.
  If NOSORT is non-nil, the list is not sorted--its order is unpredictable.
   Otherwise, the list returned is sorted with `string-lessp'.
   NOSORT is useful if you plan to sort the result yourself."
  (cons/maybe-seq
   ((if nosort identity sort)
    (filter (if match
              #(re-find (re-pattern
                         ((ns-resolve 'deuce.emacs.search
                                      'emacs-regex-to-java) match)) %)
              identity)
            (map (fn [^File f]
                   (if full
                     (.getCanonicalPath f)
                     (.getName f)))
                 (.listFiles (io/file directory)))))))
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))))

(t/defalias
  ^{:doc "The result of re-pattern."
    :forms '[t/Regex]}
  t/Regex
  #?(:clj java.util.regex.Pattern
     :cljs js/Regexp))
fluree/ledger
(ns fluree.db.ledger.docs.schema.predicates
  (:require [clojure.test :refer :all]
            [fluree.db.test-helpers :as test]
            [fluree.db.ledger.docs.getting-started.basic-schema :as basic]
            [fluree.db.api :as fdb]
            [clojure.core.async :as async]
            [clojure.string :as str]))


(deftest query-all-predicates
  (testing "Query all predicates with filter")
  (let [query-predicates {:select      {:?predicate ["*"]},
                          :where       [["?predicate" "_predicate/name" "?name"]]
                          :filter      ["(re-find (re-pattern \"^_collection\") ?name)"]
                          :prettyPrint true}
        db               (basic/get-db test/ledger-chat)
        res              (async/<!! (fdb/query-async db query-predicates))]
    (is (every? (fn [r] (-> r (get "predicate")
                            (get "_predicate/name") (str/includes? "_collection"))) res))))
Netflix/mantis-mql
(ns io.mantisrx.mql.transformers
  (:require #?@(:clj [[rx.lang.clojure.core :as rx]
                      [rx.lang.clojure.interop :as rxi]
                      [rx.lang.clojure.blocking :as rxb]
                       [clojure.data.json :as json]
                      [io.mantisrx.mql.properties :as mqlp]]
                :cljs [[cljs.reader :refer [read-string]]])
            [io.mantisrx.mql.util :as util]
            [io.mantisrx.mql.compilers.core.sampling :as samp] ;; Force loading of this namespace for compilation reasons
            [io.mantisrx.mql.compilers.core.join] ;; Force loading of this namespace for compilation reasons
            [io.mantisrx.mql.compilers.core.select] ;; Force loading of this namespace for compilation reasons
            [io.mantisrx.mql.compilers.core.operands] ;; Force loading of this namespace for compilation reasons
            [io.mantisrx.mql.compilers.core.where] ;; Force loading of this namespace for compilation reasons
            [clojure.string :as string]
            [clojure.set :as cljset])
  #?(:clj (:import rx.Observable
                   rx.schedulers.Schedulers
                   java.util.concurrent.TimeUnit
                   java.util.List
                   java.util.ArrayList
                   java.util.RandomAccess
                   java.util.Map
                   java.util.TreeMap
                   clojure.lang.RT
                   java.util.LinkedHashMap)))

(def mql-evaluators
  {:QUERY identity
   :asterisk asterisk->fn
   :SELECTLIST select-list->fn
   :AGG_LIST io.mantisrx.mql.compilers.core.select/agg-select-list->fn
   :WHERE io.mantisrx.mql.compilers.core.where/where-clause->fn
   :WHERE_TRUE (fn [& args] {:where (fn [datum] true)})
   :WHERE_FALSE (fn [& args] {:where (fn [datum] false)})
   :JOIN join->fn
   :HAVING io.mantisrx.mql.compilers.core.where/having-clause->fn
   :SAMPLE identity
   :json_sample_config sample-config->sampler
   :percent_sample_config percent-sample-config->sampler
   :AGG_OP io.mantisrx.mql.compilers.core.select/agg-op->selector+aggregator
   :as_clause (fn [n] (n {}))
   :StarBinaryExpr io.mantisrx.mql.compilers.core.where/star-binary-expr->pred
   :func_kw io.mantisrx.mql.compilers.core.select/agg-func->fn
   :number (partial literal->fn read-string)
   :property_number read-string
   :integer (partial literal->fn (comp int read-string))
   :string_literal (partial literal->fn util/strip-surround)
   :boolean_literal (partial literal->fn read-string)
   :not_search_condition not-operand->operand
   :property io.mantisrx.mql.compilers.core.operands/property->fn
   :property_with_as (fn [p as] p)
   :sw_property io.mantisrx.mql.compilers.core.operands/sw-property->fn
   :star_property io.mantisrx.mql.compilers.core.operands/star-property->fn
   :select_operand identity
   :not_operand not-operand->operand
   :distinct_operand io.mantisrx.mql.compilers.core.operands/distinct-operand->property
   :BINARY_OPERATOR identity
   :REGEX_OPERATOR identity
   :tick io.mantisrx.mql.compilers.core.operands/tick->operand
   :boolean_test io.mantisrx.mql.compilers.core.where/binary-expr->pred
   :boolean_term io.mantisrx.mql.compilers.core.where/boolean-term->pred
   :search_condition io.mantisrx.mql.compilers.core.where/search-condition->pred
   :re_expression #?(:clj #(java.util.regex.Pattern/compile % java.util.regex.Pattern/DOTALL)
                     :cljs re-pattern)
   :q_pword util/strip-surround
   :null (fn [_] nil)
   :word identity
   :pword identity
   :desc_kw identity
   })