How to Modify string Inside character, Javascript Regex -


how modify:

var = ' z ok z '; = a.replace(/z(.*)z/, function(match){ return match.trim().touppercase();}); console.log(a); // output: " z ok z " 

i expect " zthis okz ";

the uppercase work, trim function ignored

you matching spaces (*). change to:

var = ' z ok z ';    // here, you'll notice added spaces next "z" character.  = a.replace(/z (.*?) z/, " z$1z ").touppercase();    console.log(a); // output: " zthis okz "

what match between "z", , rewrites "z" directly next it.


Comments

Popular posts from this blog

javascript - How to process users in one specific order using map o each function? -

javascript - Linking from page A to a specific iframe on page B -

java - Two interface have same method name with different return type -