Midterm Study 2 Flashcards

1
Q

What is the code to match any character?

A

.

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

What is the code to match any alphanumeric character?

A

\w

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

What is the code to match any non-alphanumeric character?

A

\W

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

What is the code to match any whitespace character?

A

\s

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

What is the code to match any non-whitespace character?

A

\S

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

What is the code to match any digit character?

A

\d

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

What is the code to match any non-digit characteR?

A

\D

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

What is the code to match a, b, or c?

A

[abc]

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

What is the code to match a to g?

A

[a-g]

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

What is the code to match 6, 7, a to g?

A

[67a-g]

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

What is the code to match any character but a, b, or c?

A

[^abc]

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

What is the code to match any capital letter?

A

[A-Z]

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

What is the code to escape the next characteR?

A

\

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

What is the code to anchor at the beginning?

A

/^abc/

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

What is the code to anchor at the end?

A

/acb$/

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

What is the code to anchor both beginning and end?

A

/^abc$/

17
Q

What is the code to check for zero or one occurrence?

A

?

18
Q

What is the code to check for zero or more occurrences?

A

*

19
Q

What is the code to check for one or more occurrences?

A

+

20
Q

What is the code to check for m occurrences

A

{m}

21
Q

What is the code to check between m and n occurrences?

A

{m,n}

22
Q

How to group characters together for repetition?

A

()

23
Q

what is the code for the OR operator?

A

|

24
Q

How do you filter input for integer?

A

$_GET[“NUMBER”] FILTER_INPUT(INPUT_GET, “NUMBER”, FILTER_VALIDATE_INT)

25
Q

How would a good sanitation if else statement look?

A
26
Q

What are some of the other filter validation functions that can be used?

A

FILTER_VALIDATE_INT

FILTER_VALIDATE_FLOAT

FILTER_VALIDATE_BOOLEAN

FILTER_VALIDATE_EMAIL

FILTER_VALIDATE_URL

27
Q

What is the difference between the VALIDATE and SANITIZE functions?

A

Sanitize removes or replaces bad or incorrect characters and return the resulting string instead of just true and false testing

28
Q

How do you properly sanitize a string for special characters?

A

$safeString = filter_input(INPUT_GET, “param”,

FILTER_SANITIZE_SPECIAL_CHARS);

if ($safeString === null)

echo “

no parameter

”;

else

echo “

$safeString

”;

29
Q

How would you remove HTML tags entirely from the input?

A

FILTER_SANITIZE_STRING

30
Q

How do you process a string raw?

A

$x = “hi there”;

for ($i=0; $i<strlen></strlen>

<p>echo "$i: {$x[$i]}<br></br>";</p>

<p>}</p>

</strlen>

31
Q

How do you do regular expression matching?

A