197). The ‘$’ present in the RegExp object is called a ____________

[A]character
[B]matcher
[C]metacharacter
[D]metadata

Show Answer

198). Consider the following JavaScript statement containing regular expressions and check if the pattern matches?
var text = "testing: 1, 2, 3"; 
var pattern = /d+/g;

[A] text==pattern
[B]text.equals(pattern)
[C]text.test(pattern)
[D] pattern.test(text)

Show Answer

199). The regular expression to match any one character not between the brackets is __________
var text = "testing: 1, 2, 3"; 
var pattern = /d+/g;

[A][…]
[B][^]
[C][^…]
[D] [\D]

Show Answer

200). What does /[^(]* regular expression indicate?
var text = "testing: 1, 2, 3"; 
var pattern = /d+/g;

[A]Match one or more characters that are not open parenthesis
[B]Match zero or more characters that are open parenthesis
[C]Match zero or more characters that are not open parenthesis
[D]Match one or more characters that are open parenthesis

Show Answer

201). What will be the result when non greedy repetition is used on the pattern /a+?b/?
var text = "testing: 1, 2, 3"; 
var pattern = /d+/g;

[A]Matches the letter b preceded by the fewest number of a’s possible
[B] Matches the letter b preceded by any number of a
[C]Matches letter a preceded by letter b, in the stack order
[D] Matches letter a present in the string

Show Answer

202). What does the subexpression /java(script)?/ result in?
var text = "testing: 1, 2, 3"; 
var pattern = /d+/g;

[A] It matches “java” followed by the optional “script”
[B] It matches “java” followed by any number of “script”
[C]It matches “java” followed by a minimum of one “script”
[D] It matches “java” followed by a single “script”

Show Answer

203). What is the most essential purpose of parentheses in regular expressions?
var text = "testing: 1, 2, 3"; 
var pattern = /d+/g;

[A] Define pattern matching techniques
[B]Define subpatterns within the complete pattern
[C] Define portion of strings in the regular expression
[D]matching the complete string

Show Answer

204). The method that performs the search-and-replace operation to strings for pattern matching is _______
var text = "testing: 1, 2, 3"; 
var pattern = /d+/g;

[A]searchandreplace()
[B]add()
[C]edit()
[D]replace()

Show Answer

206). What would be the result of the following statement in JavaScript using regular expression methods?
var text = "testing: 1, 2, 3"; 
var pattern = /d+/g;

[A]Returns [“123″”456″”789”]
[B] Returns [“123″,”456″,”789”]
[C]Returns [1,2,3,4,5,6,7,8,9]
[D]Throws an exception

Show Answer

207). What will be the purpose of exec() in the following JavaScript code?
 var pattern = /Java/g;
    var text = "JavaScript is more fun than Java!";
    var result;
    while ((result = pattern.exec(text)) != null) 
    {
        alert("Matched '" + result[0] + "'" +" at position " + result.index +"; 
              next search begins at " + pattern.lastIndex);
    }

[A]Returns the same kind of array whether or not the regular expression has the global g flag
[B]Returns different arrays in the different turns of iterations
[C]Return a sub part of the array
[D]Returns a null value

Show Answer

208). What will be the output of the following JavaScript code?
 console.log(Pattern.matches("[amn]", "abcd"));

[A]true
[B]false
[C]undefined
[D]a

Show Answer

209). What will be the output of the following JavaScript code?
console.log(Pattern.matches("[amn]?", "a"));

[A]true
[B]false
[C]undefined
[D]bcd

Show Answer

210). What will be the output of the following JavaScript code?
   console.log(Pattern.matches("\\d", "1"));

[A]true
[B]false
[C]undefined
[D]1

Show Answer

211). What will be the output of the following JavaScript code?
 Console.log(Pattern.matches("[adf]+", "a"));

[A]true
[B]false
[C]undefined
[D]0

Show Answer

212). What will be the output of the following JavaScript code?
 console.log(Pattern.matches("[^abc]", "aemngq"));

[A]true
[B]false
[C]undefined
[D]1

Show Answer