- A RegExpObj
- B RegExpClass
- C RegExp
- D StringExp
- Share this MCQ
A regular expression is a pattern of characters that is used to match character combinations in strings. In JavaScript, regular expressions are represented using the RegExp
class. The RegExp
class provides methods for working with regular expressions, such as test(), exec(), and match()
.
Both strings and the RegExp
class have methods that use regular expressions. For example, the String.prototype.match()
method returns an array of strings that match a given regular expression, and the String.prototype.replace()
method replaces substrings that match a given regular expression with a replacement string.
Regular expressions are a powerful tool for pattern matching and string manipulation in JavaScript. They are often used to validate user input, search and replace text, and extract data from strings.
Share this MCQ