Trim a specific character off the start & end of a string using regex - Javascript String Operation

Javascript examples for String Operation:String Replace

Description

Trim a specific character off the start & end of a string using regex

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from  w  ww . j  av  a  2s  .  c o  m*/

var myString = '"""""""""""""test " test""""""""""""""';
myString = myString.replace(/^"+|"+$/g, '');
console.log(myString);


    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials