Bạn có chắc chắn muốn xóa bài viết này không ?
Bạn có chắc chắn muốn xóa bình luận này không ?
Java Regular Expression Overview – Syntax
https://grokonez.com/java/java-regular-expression-overview-syntax
Java Regular Expression Overview – Syntax
Regular expression (regex) defines patterns to recognise strings. Those patterns can be anything: a character, a specific string, a group of special characters or a combination of them. We can use Regular expression for searching, extracting, and modifying text.
This tutorial shows you an overview of Regular Expression Syntax.
I. Syntax
1. Characters
To define content of a regex pattern, we use many kinds of character classes:
character | match | abbreviation of |
---|---|---|
. | any single character except newline (we can use m option to match the newline) |
|
\d | a digit | [0-9] |
\D | a non-digit | [^0-9] |
\s | a whitespace character | [ \t\n\x0B\f\r] |
\S | a non-whitespace character | [^\s] |
\w | a word character | [a-zA-Z_0-9] |
\W | a non-word character | [^\w] |
When using in real Java code, except '.', we should double the 'escape' (\) :
https://grokonez.com/java/java-regular-expression-overview-syntax
Java Regular Expression Overview – Syntax




