Clojure – Regular Expressions re-find

Clojure Regular Expressions re-find

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

re-find

Returns the next regex match, if any, of string to pattern, using java.util.regex.Matcher.find()

Syntax

Following is the syntax.

(re-find pat str)

Parameters βˆ’ β€˜pat’ is the pattern which needs to be formed. β€˜str’ is the string in which text needs to be found based on the pattern.

Return Value βˆ’ A string if a match is found based on the input string and pattern.

Example

Following is an example of re-find in Clojure.

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

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

Output

The above program produces the following output.

123

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply