Clojure - Regular Expressions re-pattern


Advertisements

re-pattern

Returns an instance of java.util.regex.Pattern. This is then used in further methods for pattern matching.

Syntax

Following is the syntax.

(re-pattern pat)

Parameters − ‘pat’ is the pattern which needs to be formed.

Return Value − A pattern object of the type java.util.regex.Pattern.

Example

Following is an example of re-pattern in Clojure.

(ns clojure.examples.example
   (:gen-class))

;; This program displays Hello World
(defn Example []
   (def pat (re-pattern "\\d+")))
(Example)

The above program will create a pattern object, which will be a pattern of one or more digits.

clojure_regular_expressions.htm
Advertisements