Regex Basics Flashcards

1
Q

Backslash \

A

escapes the character

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The Pipe |

A

Or

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The Question mark ?

A

The last item is optional, betyder att nåt får komma 0 eller 1 gång

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Parentheses

A

Used when you want to match several outcomes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Square brackets []

A

Match only one out of a set or a range of characters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Braces {}

A

When you want to repeat the last item, or set a range how of the minimum and maximum repeats

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

The Dot .

A

Match any character except linebreaks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

The + Sign

A

Matches one or more of the former items, betyder att nåt måste komma minst en gång

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

The * sign

A

Stars will match zero or more of the previous items, betyder ingenting eller hur mycket som helst

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

The .* Sign

A

get everything.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

The Caret ^

A

match only strings that start exactly with

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

The Caret in brackets [^0-9]

A

match only characters that are not right after the caret.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

The dollar sign $

A

don’t match if the target string has any characters beyond where I have placed the dollar sign

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

\w

A

word

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

\d

A

digit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

\s

A

whitespace

17
Q

\W

A

not word

18
Q

\D

A

not digit

19
Q

\S

A

not whitespace

20
Q

g flag

A

Global flag With this flag the search looks for all matches, without it – only the first match is returned.

21
Q

i flag

A

Ignore case sensitivity, With this flag the search is case-insensitive: no difference between A and a (see the example below).

22
Q

m flag

A

multiline flag, Multiline mode (covered in the chapter Multiline mode of anchors ^ $, flag “m”).

23
Q

\b

A

word boundary

24
Q

\t

A

escape tab

25
Q

\n

A

escape linefeed

26
Q

\r

A

escape carriage return

27
Q

\1

A

backreference to group #1

28
Q

(?:abc)

A

non-capturing group

29
Q

(?=abc)

A

positive lookahead

30
Q

(?!abc)

A

negative lookahead

31
Q

a*

A

0 or more

32
Q

a+

A

1 or more

33
Q

a?

A

0 or 1

34
Q

a{5} a{2,}

A

exactly 5, two or more

35
Q

a{1,3}

A

between one and 3

36
Q

a+? a{2,}?

A

match as few as possible

37
Q

u flag

A

Enables full unicode support. The flag enables correct processing of surrogate pairs. More about that in the chapter Unicode: flag “u” and class \p{…}.

38
Q

Metacharacter

A

Metacharacters are the building blocks of regular expressions. Characters in RegEx are understood to be either a metacharacter with a special meaning or a regular character with a literal meaning.