\{\} in regular expression--number of occurrences of the matching pattern

Source: Internet
Author: User

Regular Expressions:

\{\} matches the number of occurrences of a character

Use * to match all matching results once, but if you set the number of times, you should use \{\}, this mode has three forms.

Pattern\{n\} match pattern appears n times

Pattern\{n,\} match pattern appears at least n times

Pattern\{n,m\} match pattern appears n to M times, N,m is any integer between 0-255


A\{2\}b Match value is AaB

A\{4\}b Match value is Aaaab or Aaaaaab, but cannot be Aaab

A\{3,5\} match value is Aaab,aaaab,aaaaab

Note: Regular expression single metacharacters are not difficult to use, especially if multiple meta-character sets appear mixed

grep ' ^h.[a-z,a-z]s\{2,4\}c$'./test

This article is from the "Not So Simple" blog, be sure to keep this source http://hungss5657.blog.51cto.com/8011603/1631374

\{\} in regular expression--number of occurrences of the matching pattern

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.