Regex Flashcards

1
Q

beginning of line

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

end of line

A

$

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

Pick one of a list of characters

A

Use []

[Bb][Uu][Ss][Hh] # this is basically for case insensitive BUSH

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

Specify range of characters

A

[0-9][a-zA-Z]

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

You don’t want a list of characters at the end of line

A
[^?.]$
will match the lines
i like basketballs
6 and 9
dont worry... we all die anyway!
Not in Baghdad
helicopter under water? hmmm
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

any single character

A

use dot “.”
9.11 will match
9-11
9:10

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

find one of two words

A

will match the lines
is firewire like usb on none macs?
the global flood makes sense within the context of the bible

(pipe)
flood|fire

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

find one of two words, lower case or upper case where one of the words specifically must appear at the beginning of the line

A

^[Gg]ood|[Bb]ad

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

^([Gg]ood|[Bb]ad)

A

can have good or bad at the beginining of a line, case doesn’t matter

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

Search for George W. Bush with the “W” as optional

A

Gg]eorge( [Ww].)? [Bb]ush

must escape the period by \

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

Escape special characters like $^.

A

\

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

repeating characters

A

*
.* means repeat any character as many times as you want
p* means repeat p as many times you want
(.*) have parenthesis with any characaters in the middle you want

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

The * and + signs are metacharacters used to indicate repetition; * means “any number, including none, of the item” and + means “at least one of the item”

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

what does [^]

A

indicates negation,

[^?.]$ means match things that do not end in question mark or period at the end.

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

turn of grediness of * off

A

use .*?

*? will find the shortest match

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