javascript - jHow to replace string from a part of given string? -


var ans = '#1>2,2,2,0,#2>3,2,1' 

i want remove 2 immediate after #1> not #2>. expected result is:

ans = '#1>0,#2>3,2,1' 

how can using jquery?

try one

var ans = '#1>2,2,2,0,#2>3,2,1'  ans.replace(/#1>(2,{0,})+/g,function() {     return "#1>" }) 

output:

#1>0,#2>3,2,1 

test here


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -