Node.js Regular Expression

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

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.

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

Read more articles


General Knowledge



Learn Popular Language