Midterm Study 2 Flashcards
What is the code to match any character?
.

What is the code to match any alphanumeric character?
\w
What is the code to match any non-alphanumeric character?
\W
What is the code to match any whitespace character?
\s
What is the code to match any non-whitespace character?
\S
What is the code to match any digit character?
\d
What is the code to match any non-digit characteR?
\D
What is the code to match a, b, or c?
[abc]
What is the code to match a to g?
[a-g]
What is the code to match 6, 7, a to g?
[67a-g]
What is the code to match any character but a, b, or c?
[^abc]
What is the code to match any capital letter?
[A-Z]
What is the code to escape the next characteR?
\
What is the code to anchor at the beginning?
/^abc/
What is the code to anchor at the end?
/acb$/
What is the code to anchor both beginning and end?
/^abc$/
What is the code to check for zero or one occurrence?
?
What is the code to check for zero or more occurrences?
*
What is the code to check for one or more occurrences?
+
What is the code to check for m occurrences
{m}
What is the code to check between m and n occurrences?
{m,n}
How to group characters together for repetition?
()
what is the code for the OR operator?
|
How do you filter input for integer?
$_GET[“NUMBER”] FILTER_INPUT(INPUT_GET, “NUMBER”, FILTER_VALIDATE_INT)
How would a good sanitation if else statement look?

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
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
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
”;
How would you remove HTML tags entirely from the input?
FILTER_SANITIZE_STRING
How do you process a string raw?
$x = “hi there”;
for ($i=0; $i<strlen></strlen>
<p>echo "$i: {$x[$i]}<br></br>";</p>
<p>}</p>
</strlen>
How do you do regular expression matching?
