Q:

Write a node.js program to replace two or more a's with the letter b on the given string using Regular Expression

belongs to collection: Node.js programming Exercises

0

Write a node.js program to replace two or more a's with the letter b on the given string using Regular Expression

aaewewedsdewddsxac

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Solution

JavaScript has powerful regular expression support.

A certain number of string functions can take arguments that are regular expressions to perform their work. These regular expressions can either be entered in literal format or as a call to the constructor of a RegExp object. The RegExp object is used for matching text with a pattern.

console.log("aaewewedsdewddsxac".replace(new RegExp("[Aa]{2,}"), "b"));

Output of the above code:

bewewedsdewddsxac

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

There is a given object, write node.js program to ... >>
<< Write a node.js program to check request header fo...