I have following string.
var str = "abc, abcd, abc, abcf, abc, abc";
I want to remove abc
from a given string with , (space)
. Basically, I want output something like below.
var output = "abcd, abcf";
Note:- If possible give regex solution(with one replace only).
Things I have tried:-
1) 1st approach
var str = "abc, abcd, abc, abcf, abc, abc";
var w = "abc";
var output = str.split(", ").filter(x => !(x === w)).join(", ");
console.log(output);
Using one replace()
var str = "abc, abcd, abc, abcf, abc, abc";
var rep = "abc";
var r = new RegExp("(, "+rep+"(?![a-z]))|("+rep+"(?![a-z]), )","g");
str = str.replace(r, "");
console.log(str);
I got an object which looks like this : { "a": "string not empty", "b": { "c": "string not empty", }, "d": { "e": false, "f": 0, "g": true, ...
I got an object which looks like this : { "a": "string not empty", "b": { "c": "string not empty", }, "d": { "e": false, "f": 0, "g": true, ...
I am following a tutorial in order to perform Asynchronous validation in Angular. What I am trying to achieve is my custom validator which is shouldBeUnique should be call after delay of 2 seconds. I ...
I am following a tutorial in order to perform Asynchronous validation in Angular. What I am trying to achieve is my custom validator which is shouldBeUnique should be call after delay of 2 seconds. I ...
Why jquery parent child selector is not working here. Here article element has it's children element section, and section contains html select tag. So, with parent child logic, it has to work, isn'...
Why jquery parent child selector is not working here. Here article element has it's children element section, and section contains html select tag. So, with parent child logic, it has to work, isn'...
I have this body div(ng-class="toggle ? 'nav-open' : 'nav'") .container .logo img(src='images/logo.png') span Motto ul(ng-class="toggle ? 'menu-open' : ...
I have this body div(ng-class="toggle ? 'nav-open' : 'nav'") .container .logo img(src='images/logo.png') span Motto ul(ng-class="toggle ? 'menu-open' : ...