N6. Java Regex Flashcards
What is a possible use of a Regular Expression?
used for parsing and checking user inputs and messages within protocol
REGEX
^ character
beginning of a line
REGEX
$ character
end of a line
REGEX
\ character
escapes a meta character
REGEX
\d
[0-9] digits
REGEX
\D
[^0-9] (anything other than digits 0-9)
REGEX
\w
word character (same as [A-Za-z0-9_])
REGEX
\b
word boundary
REGEX
[abc]
match ‘a’, ‘b’, or ‘c’
REGEX
[^abc]
match anything but ‘a’, ‘b’, or ‘c’
REGEX
[a-z]
match characters in the range ‘a’-‘z’
REGEX
repetition characters
{ } curly brackets
REGEX define a class of characters
[ ] square brackets
REGEX
\d{2,5}
between 2 and 5 digits
REGEX
\d{5,}
5 or more digits
REGEX
\s
whitespace character (distinction with \\S - non-whitespace character)
REGEX quantifiers
* symbol
0 or more occurrences
REGEX quantifiers
+ symbol
1 or more occurrences
REGEX quantifiers
? symbol
0 or 1 occurrence
REGEX
define a group
( ) round brackets