Clojure (16) -- Regular Expression

Source: Internet
Author: User

Regular Expression
Re-pattern function:
The function (re-pattern) accepts a string parameter and returns a regular expression style (java. util. regex. Pattern class instance ). This style can be used for regular expression matching.

You can also use a macro to directly input a regular expression in text format: Use the # symbol before the string. The expression is the same as that generated using the re-pattern function. For example, the following representation is the same as that in the previous example:

Re-matcher function:
The re-matcher function accepts two parameters: a regular expression style and a string. Returns a stateful "matcher" object, which is provided to other regular functions rather than directly providing styles. Matchers is an instance of the java. util. regex. Matcher. Class.
The def function is used to define variables, which will be described later.

Ii. Use a regular expression: 
Re-find function:
Re-find accepts a style with a string or a matcher. After each call, the next matching result in matcher is returned.

Re-matches function:
Re-matches accepts two parameters: a regular expression style and a string. Returns any string that matches the regular expression style. If no match exists, returns nil. For example, the following code:

Re-seq function:
Re-seq accepts a style and a string. It returns a lazy sequence (lazy sequence) that uses matcher (this sequence is in a continuous style matching string)

Re-groups function:
Accept a matcher and return the set of discovery and matching from proximity. If no nested set exists, a fully matched string is returned. If a nested set exists, the vector set is returned. The first element is completely matched (non-nested)


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.