Regular Expressions Flashcards

1
Q

Show how to search if ‘where’ is at the beginning of the sentence

A

^where

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

Select every possible character

A

.

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

In terms of the below list, use a character set to find all of them.

Find all words except those using a character set

bar ber bir bor bur

A

b[eioua]r

b[^aeiou]r

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

Find all letters e through o

A

[e-o]

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

Show how you would search the below and get all the words using e in our search. We are fine with e showing up one or more times, or just never

br ber beer

A

be*r

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

Search for everything except for br below. So we want to search for if e occurs one or more times, but not never

A

be+r

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

Search saying the u in color is optional (zero or one, not zero, one or more.)

color colour

A

colou?r

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

Search for words that start with ‘be’ and end with 4.
be should only occur only two times and that’s it.

Now show if we want the e character to show up AT LEAST 3 times in a row.

Now show words that e can show up 1 - 3 times

A

be{2}r

be{3,}r

be{1,3}r

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

Show an expression that would find 4 numbers in a row

A

[0-9]{4}

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

Create two groups, one that contains ‘ha’ and the other that contains ‘haa’

A

(ha)-\1,(haa)-\2

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

What is a pip character used for?

A

Allows you to specify that and express can be in different expressions.

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

use a pipe character to select all from the below
cat rat dog

A

(c|r)at|dog

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

What is the escape character?

A

\

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

use the escape character to find
* and .

A

(*|.)

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

Search for only the numbers at the beginning of the statements

  1. this
  2. that
  3. other
A

^[0-9]

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

Find only the expressions that end with html

https://domain.com/what-is-html.html
https://otherdomain.com/html-elements
https://website.com/html5-features.html

17
Q

Use the word Character to find letters numbers and underscores

18
Q

Use the Except Word Character to find characters other than letters, numbers, and underscores.

19
Q

use the Number Character to only find number characters

20
Q

use the Except Number Character to only find everything but number characters

21
Q

Use the Space Character to find space characters

22
Q

Use the Except Space Character to find everything except space characters

23
Q

What do we use if we want to search for a phrase we’re writing to come before or after another phrase?

A

a Lookaround

24
Q

Using a Lookahead, find only the three character.

Next, look for only numbers that don’t have pm after them with the Negative Lookahead

Date: 4 Aug 3PM

A

\d+(?=PM)

\d+(?!PM)

25
Q

Using the Positive Lookbehind, find only the numbers preceeded by a $ sign

Next find numbers that aren’t preceeded by the $ sign

Product Code: 1064 Price: $5

A

(?<=$)\d+

(?<!$)\d+