ExamVeda
Login
Home
31
Consider the following statement containing regular expressions
var text = "testing: 1, 2, 3"; 
var pattern = /d+/g;
In order to check if the pattern matches, the statement is
Discuss
Answer & Solution
Answer: Option D
Solution:
The given pattern is applied on the text given in the paranthesis.
32
The regular expression to match any one character not between the brackets is
Discuss
Answer & Solution
Answer: Option C
Solution:
The [^…] character class is used to match or draw any one character not between the brackets.
33
What does /[^(]* regular expression indicate ?
Discuss
Answer & Solution
Answer: Option C
Solution:
We should always be careful while using * and ? as repetition characters as they may match zero instances of whatever precedes them, they are allowed to match nothing.
34
What will be the result when non greedy repetition is used on the pattern /a+?b/ ?
Discuss
Answer & Solution
Answer: Option A
Solution:
Using non greedy repetition may not always produce the results you expect. /a+?b/ matches the letter b preceded by the fewest number of a’s possible.
35
What does the subexpression /java(script)?/ result in ?
Discuss
Answer & Solution
Answer: Option A
Solution:
The subexpression /java(script)?/ matches “java” followed by the optional “script”.
36
What is the most essential purpose of parantheses in regular expressions ?
Discuss
Answer & Solution
Answer: Option B
Solution:
When a regular expression is successfullyy matched against a target string, it is possible to extract the portions of the target string that matched any particular paranthesized subpattern. The essential purpose of parantheses in regular expressions is to define subpatterns within the complete pattern.
37
The method that performs the search-and-replace operation to strings for pattern matching is
Discuss
Answer & Solution
Answer: Option B
Solution:
The replace() method performs a search-and-replace operation. It takes a regular expression as its first argument and a replacement string as its second argument.
38
What would be the result of the following statement in JavaScript using regular expression methods ?
Discuss
Answer & Solution
Answer: Option B
Solution:
The split() method can take regular expressions as its arguments. The split() method generally breaks the string on which it is called into an array of substrings, using the argument as a separator.
39
The Crockford’s subset doesnot include which function in JavaScript?
Discuss
Answer & Solution
Answer: Option A
Solution:
The Crockford’s subset does not include the with and continue statements or the eval() function. It defines functions using function definition expressions only and does not include the function definition statement.
40
Why does JavaScript subset disallow == and !=?
Discuss
Answer & Solution
Answer: Option B
Solution:
The subset does not include the comma operator, the bitwise operators, or the ++ and — operators. It also disallows == and != because of the type conversion they perform, requiring use of === and !== instead.