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?

17
Q

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

18
Q

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

19
Q

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

20
Q

What is the code to check for m occurrences

21
Q

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

22
Q

How to group characters together for repetition?

23
Q

what is the code for the OR operator?

24
Q

How do you filter input for integer?

A

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

25
How would a good sanitation if else statement look?
26
What are some of the other filter validation functions that can be used?
FILTER\_VALIDATE\_INT FILTER\_VALIDATE\_FLOAT FILTER\_VALIDATE\_BOOLEAN FILTER\_VALIDATE\_EMAIL FILTER\_VALIDATE\_URL
27
What is the difference between the VALIDATE and SANITIZE functions?
Sanitize removes or replaces bad or incorrect characters and return the resulting string instead of just true and false testing
28
How do you properly sanitize a string for special characters?
$safeString = filter\_input(INPUT\_GET, "param", FILTER\_SANITIZE\_SPECIAL\_CHARS); if ($safeString === null) echo " no parameter "; else echo " $safeString ";
29
How would you remove HTML tags entirely from the input?
FILTER\_SANITIZE\_STRING
30
How do you process a string raw?
$x = "hi there"; for ($i=0; $i

echo "$i: {$x[$i]}
";

}

31
How do you do regular expression matching?