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

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -