Clojure – Regular Expressions re-pattern

Clojure Regular Expressions re-pattern

In this guide, we will discuss Clojure Regular Expressions re-pattern.

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.

Next Topic : Click Here

This Post Has One Comment

Leave a Reply