Regular expression unary characters and character groups

Source: Internet
Author: User

1, ^ symbol---the beginning of a row

// returns an array of text immediately beginning with C, immediately following a T! 

2, $---Represents the end of a line

// returns the text array output that ends with Y, followed by the previous one, R   : Ry

3. [...] Indicates that a character group is used to match a string of characters

If we need to search for the word "gray", but also not sure if he writes "Gray", this time you can use the regular expression structure [...] -Character groups. He allows the user to list characters that they want to match within a character group.

E means match character e,a means match character A,[ea] means match A or e, so to match "gray" can write this: Gr[ea]y, the first to find a G, followed by an R, then an E or a, immediately after this last is Y.

Note: The internal match in the character group is not the same as the outside, he represents the or.

// The return begins with G, followed by an R, followed by A or e, followed by a Y   output: Gray

You can enumerate any number of characters in a group of characters, for example [123456] matches any number in 1 to 6, which can be used as part of "h<123456>" to match

3.1 Character Group Metacharacters

Within a character group, the character group metacharacters '-' (hyphens) represent a range, as follows, ' <H[1-6]> ' and ' <H[123456]> ' are the same!

' [0-9] ' and ' [A-z] ' are common ways to match commonly used numbers and lowercase sub-females! can also be multi-range is allowed, for example, we want to match a word must start with an alphabetical array underscore, the code can write:

Regular expression unary characters and character groups

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.