How do you create a character class with JavaScript?
What will be an ideal response?
You use acharacter classin a regular expression to treat multiple characters as a single item. You create a character class by enclosing the characters that make up the class within bracket[]metacharacters. Any characters included in a character class represent alternate characters that are allowed in a pattern match. As an example of a simple character class, consider a word with alternative spellings, such as "analyze" (U.S.) or "analyse" (British). The following code uses a character class to check for either spelling of this word by specifying that eithersorzcould be the sixth character in the string:?var wordPattern =/analy[sz]e/;var testResult = wordPattern.test("analyse"); // truetestResult = wordPattern.test("analyze"); // true
You might also like to view...
Ethernet uses which of the following access methods?
a. random access b. CSMA/CD c. time division d. polling
Write a script that inputs five numbers and determines and outputs HTML text that displays the number of negative numbers input, the number of positive numbers input and the number of zeros input.
What will be an ideal response?