ClojureDocs

Nav

Namespaces

includes?

clojure.string

Available since 1.8
  • (includes? s substr)
True if s includes substr.
2 Examples
;; String-oriented alternative to regular-expression functions in core
(clojure.string/includes? "clojure" "cl")
;;=> true

;; Does *not* work with regular expressions!
(clojure.string/includes? "clojure" #"cl")
;;=> java.util.regex.Pattern cannot be cast to java.lang.CharSequence
;;   (java.lang.ClassCastException)

;; Be careful when you uses with maps 
(includes? (str (:name {})) "Bob Alice")
;;=> false

(includes? (:name {}) "Bob Alice")
;;=> Execution error (NullPointerException) at user/eval63454 (REPL:1).
;;Cannot invoke "Object.toString()" because "s" is null
See Also

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

Added by bfontaine

Return index of value (string or char) in s, optionally searching forward from from-index. Return ...

Added by bfontaine
0 Notes
No notes for includes?