Basic Syntax Flashcards Preview

Regular Expressions > Basic Syntax > Flashcards

Flashcards in Basic Syntax Deck (31)
Loading flashcards...
1

\Q...\E

For example: \Q+-*/\E

Matches the characters literally, suppressing the meaning of special characters.

For example, match +-*/

2

\a

Matches the bell character

3

\e

Matches the escape character

4

\f

Matches the form feed character

5

\v

Matches the vertical tab character

6

[ ]

Symbol(s) used to encapsulate a character class. A character class matches a single character out of all the possibilities offered by the character class.

7

^ immediately following a [

Negates the character class, causing it to match a single character not listed in the character class.

8

\d

Matches a digit

9

\w

Matches word characters (letters, digits and underscores)

10

\s

Matches whitespace (spaces, tabs and linebreaks)

11

\D

Matches a character that is not a digit

12

\W

Matches a character that is not a word character (letters, digits, and underscores)

13

\S

Matches a character that is not a whitespace

14

\b

Matches a backspace character (inside a character class [ ] )

15

\t

Matches a tab character (inside a character class [ ] )

16

. (dot)

Matches any single character except line break characters

17

\n

Matches a line break character

18

^

Matches at the start of the string the regex pattern is applied to

19

$

Matches at the end of the string the regex pattern is applied to.

20

\b

Matches at the position between a word character (anything matched by \w) and a non-word character (anything matched by [^\w] or \W) as well as at the start and/or end of the string if the first and/or last characters in the string are word characters.

21

\B

Matches at the position between two word characters (i.e the position between \w\w) as well as at the position between two non-word characters (i.e. \W\W).

22

| (pipe)

Causes the regex engine to match either the part on the left side.

23

?

Makes the preceding item optional.

24

*

Repeats the previous item zero or more times.

25

+

Repeats the previous item once or more.

26

{n} where n is an integer >= 1

Repeats the previous item exactly n times.

27

{n,m} where n >= 0 and m >= n

Repeats the previous item between n and m times.

28

{n,} where n >= 0

Repeats the previous item at least n times.

29

\1 through \9

Matches backreferences (previous sets of expressions enclosed in parentheses)

30

\G

Matches at the position where the previous match ended, or the position where the current match attempt started.