JavaScript From Beginner To Advanced

0% completed

Previous
Next
Quiz
What does the regular expression '/^a...s$/' match?
A
Any string that starts with 'a' and ends with 's' with exactly three characters in between.
B
Any string that starts with 'a' and ends with 's' with at least three characters in between.
C
Any string that contains 'a' followed by any three characters and an 's' anywhere in the string.
D
Any string that starts and ends with any characters and contains 'a' followed by 's'.
Which method is used to test for a match in a string?
A
RegExp.match()
B
RegExp.exec()
C
RegExp.test()
D
String.find()
What is the output of the following code? console.log(/abc/.test('abcde'));
A
undefined
B
0
C
true
D
false
Which flag is used with a regular expression to make it case-insensitive?
A
g
B
m
C
i
D
s
What does the following regular expression match? /[\d]{2,4}/
A
Exactly two to four digits
B
Two to four non-digit characters
C
At least two, but no more than four, digits
D
Any number, with digits in groups of two to four
Which regular expression will find all instances of the word "the" regardless of case in a string?
A
/the/g
B
/the/i
C
/the/gi
D
/^the$/gi
How do you use a regular expression to match any character except newline?
Choose all correct options
/.+/
/./
/.*/
/[^.\n]/
What does the '?' character signify in a regular expression?
A
The preceding character is optional and may appear zero or one time.
B
It marks the start of a non-capturing group.
C
It is used as a quantifier to indicate one or more times.
D
The backslash \ is used to escape special characters to treat them as literals, not '?'.

.....

.....

.....

Like the course? Get enrolled and start learning!
Previous
Next