Android Regular Expression

Source: Internet
Author: User
Escape characters

\ Escape followed by metacharacters

\ Q escape all followed metacharacters until \ e

Use \ e and \ q together to escape all metacharacters contained

\ Backslash

\ Uhhhh hexadecimal Unicode Character U + hhhh

\ Xhh hexadecimal Unicode Character U + 00hh

\ Cx ascii control character ^ X (SO \ ch represents ^ h, U + 0008)

\ A ascii character U + 0007, bell

\ E ASCII character U + 001b, ESC

\ F ASCII character U + 000c

\ N ASCII character U + 000a, line feed

\ R ASCII character U + 000d, press ENTER

\ T ASCII character U + 0009, used to create a tab

Character class

[ABC] any character in the Set

[A-c] any character in the set defined by the range

[^ ABC] any character in the complement set

[[A-F] [0-9] any character in the Union

[[A-Z] & [jkl] any character in the intersection

. Any character

\ D any number character

\ D any non-Numeric Character

\ S any blank character

\ S any non-blank character

\ W any letter

\ W any non-letter character

\ P {name} any character that belongs to the specified name character class

\ P {name} any character that does not belong to the specified name character class

Quantifiers

* 0 or multiple

? 0 or 1

+ 1 or more

{N} Exactly n

{N,} At Least n

{N, m} must be at least N and cannot exceed M

<Quantifiers> the default value is greedy quantifiers. Greedy quantifiers are called "greedy" because they force the matters to read (or eat) the entire input string to give priority to the first match, if the first attempt fails to match (for the entire input string), The matcher will try again by rolling back one character of the entire string until a match is found, or there are no more characters on the left for rollback. The quantizer used by the operator in the expression. In the end, it tries to match by 1 or 0 characters.

<Quantifiers>? The stubborn quantifiers use the opposite approach: starting from the beginning of the input string, so each time you barely swallow a character to find a match, they will eventually try the entire input string.

<Quantifiers> + the encroaching quantifiers always swallow the entire input string and try to match the string once (only once. Unlike greedy quantifiers, encroaching quantifiers will never return back, even if this is done to allow all the matches to succeed.

Boundary

^ Beginning of Line

$ End of line

\

\ B word boundary

\ B Non-word boundary

End of a match on \ G

The end of the \ Z input. It is only used for the final terminator (if any)

\ Z input end

Related Article

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.