Chapter 10

¡Supera tus tareas y exámenes ahora con Quizwiz!

Which of the following regular expressions will search for a word with a minimum of 4 character and having the letters 'b' and 'sh' such that there is a character between them. for e.g. 'bush', 'ambush', 'bushel', 'bash'? REGEXP '[b]*[s][h]' REGEXP '[b].[s][h]' REGEXP '[b][a-z]{2}[s][h]' REGEXP '*b*sh*'

REGEXP '[b].[s][h]'

A database field named Comments in a table named Products may contain text starting with the name Shawn or Sean. Write a simple SQL statement using regular expressions to filter for records meeting this criteria. SELECT * FROM Products WHERE Comments REGEXP '^[Shawn]' OR Comments REGEXP '[Sean]' SELECT * FROM Products WHERE Comments REGEXP '^[S](haw|ea)[n]' SELECT * FROM Products WHERE Comments REGEXP '^[S|h|a|w|n]' OR Comments REGEXP '^[S|e|a|n]' SELECT * FROM Products WHERE Comments REGEXP '^S[hawn]' OR '^S[ean]'

SELECT * FROM Products WHERE Comments REGEXP '^[S](haw|ea)[n]'

The name of the table below is Survey1 and there are two fields in this table, namely RespondentFullName and Answer. Answer contains a response to a question in a survey, confirming whether or not they wish to be contacted for further details regarding the survey. In some of the answers provided, there an email address is provided. Which of the statements will NOT find the valid email addresses? Suggested answers with SQL statements are provided. In this question, consider any string given as [email protected] as a valid email address - i.e. [email protected] is considered a valid address. SELECT * FROM Survey1 WHERE Answer LIKE '%[@][A-z]%[.][c][o][m]%' SELECT * FROM Survey1 WHERE Answer LIKE '%[@][A-z]%[.][c][o][m][.]%' SELECT * FROM Survey1 WHERE Answer LIKE '%[@][A-z]%[.][e][d][u]%' SELECT * FROM Survey1 WHERE Answer LIKE '%[@][A-z]%[.][com].%'

SELECT * FROM Survey1 WHERE Answer LIKE '%[@][A-z]%[.][com].%'

The table below is named Survey1 and the RespondentFullName field is defined as nchar(50) while the LuckyDrawNumber field is defined as bigint. The organizers of a survey have decided that any LuckyDrawNumber values with the sequence of digits '789' will win a prize. Which SQL statement containing a regular expression would be the correct one? SELECT * FROM Survey1 WHERE LuckyDrawNumber = 789 SELECT * FROM Survey1 WHERE LuckyDrawNumber LIKE '%[7][8][9]%' SELECT * FROM Survey1 WHERE LuckyDrawNumber LIKE '789' SELECT * FROM Survey1 WHERE LuckyDrawNumber[0] = '7' AND LuckyDrawNumber[1] = '8' and LuckyDrawNumber[2] = '9'

SELECT * FROM Survey1 WHERE LuckyDrawNumber LIKE '%[7][8][9]%'

The name of the single column table below is Survey1 with a field called RespondentFullName. You are asked to write a query to list all records that have the occurrence of the substring P*T in the value of the RespondentFullName field. The '*' indicates any letter in the English alphabet in this situation. Thus, names containing 'Peter' and 'Patricia' should be listed. Which query would be correct (ignoring case sensitivity in this case)? SELECT * FROM Survey1 WHERE RespondentFullName LIKE '%[P][A-Z][T]%' SELECT * FROM Survey1 WHERE RespondentFullName LIKE '%[P?T]%' SELECT * FROM Survey1 WHERE RespondentFullName LIKE '%[P*T]%' SELECT * FROM Survey1 WHERE RespondentFullName = '%[P][A-Z][T]%'

SELECT * FROM Survey1 WHERE RespondentFullName LIKE '%[P][A-Z][T]%'

The table below is named Survey1 and the two fields in this table are RespondentFullName and ContactNo. Which SQL statement using a regular expression would be used to exclude all names containing the substring 'PE' (case sensitivity not important) from being listed? SELECT * FROM Survey1 WHERE RespondentFullName NOT LIKE '%[P][E]%' SELECT * FROM Survey1 WHERE RespondentFullName NOT LIKE '[P][E]%' SELECT * FROM Survey1 WHERE RespondentFullName NOT LIKE '*[P][E]*' SELECT * FROM Survey1 WHERE RespondentFullName != '[P][E]%'

SELECT * FROM Survey1 WHERE RespondentFullName NOT LIKE '%[P][E]%'

Which of the below SQL statements will search for two or three consecutive 'r' character in the comments field of the Message table? SELECT Comments FROM Message WHERE Comments REGEXP 'r{2,3}' SELECT Comments FROM Message WHERE Comments REGEXP 'r{2}' SELECT Comments FROM Message WHERE REGEXP 'rrr' OR Comments REGEXP 'rr' SELECT Comments FROM Message WHERE REGEXP 'rr'

SELECT Comments FROM Message WHERE Comments REGEXP 'r{2,3}'

Given the text: I use study.com to help me understand regular expressions. And given the regular expression: st. (case sensitive) How many search results will the regular expression find? 0 2 3 1

2

A single period (.) in a regular expression, outside of groups of other exceptions, represents what? Any single character A space The end of a sentence Any punctuation mark

Any single character

Given the regular expression: a{5,} How many a's could be matched in a single instance? Zero to five One to five Five or more Five to ten

Five or more

The following are some values which are found in the ContactNo field in the Employee table - '03-40093812', '04-65991342', '07-20039184', ' 06-40129144'. Which numbers will the below SQL query return? SELECT ContactNo FROM Employee WHERE ContactNo REGEXP '91[0-9]4' I. 03-40093812 II. 04-65991342 III. 07-20039184 IV. 06-40129144 III and IV I, II, III and IV II and III II, III and IV

II, III and IV

A SQL statement with a regular expression to list out the occurrence of values containing the substring 'Th' in the Description field in table named TABLE1 is needed. Here case sensitivity is important. Which SQL statement will accomplish this task? SELECT Description FROM TABLE1 WHERE Description COLLATE Latin1_General_BIN LIKE '[T][h]% SELECT Description FROM TABLE1 WHERE Description COLLATE Latin1_General_BIN LIKE '%[t][h]%'; SELECT Description FROM TABLE1 WHERE Description COLLATE Latin1_General_BIN LIKE '%[T][h]%'; SELECT Description FROM TABLE1 WHERE Description COLLATE Latin1_General_BIN LIKE '%[T][H]%';

SELECT Description FROM TABLE1 WHERE Description COLLATE Latin1_General_BIN LIKE '%[T][h]%';

What are regular expressions used to search? Images Videos Text Amazon.com

Text

What is something a regular expression CANNOT be used for? Validating equation answers Replacing text Validating date formatting Searching for repetitive characters

Validating equation answers

Which of the following regular expressions will match the word 'MaMa' ('Ma' occurring twice)? WHERE Word REGEXP '([M][a]){2}' WHERE Word REGEXP '[m].[a]{2}' WHERE Word REGEXP '[m][a]{2}' WHERE Word REGEXP '[ma]{2}'

WHERE Word REGEXP '([M][a]){2}'


Conjuntos de estudio relacionados

Cardiovascular Flashcards, Exam two

View Set

Cell and Molecular Biology Final Exam

View Set

Module 2 Chapter 6 Network Essentials

View Set

English: The Iroquois Creation Myth: "The World on Turtle's Back"

View Set

Fetal Pig Muscles - Origin and Insertion, Action

View Set