Replace numbers between [] like [123] - Javascript RegExp

Javascript examples for RegExp:Bracket

Description

Replace numbers between [] like [123]

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  w w.  j a v a 2  s.  c  om*/
function replaceStr(string,orgText,replaceText){
  var res = string.replace(orgText, replaceText);
  return res;
}
console.log(replaceStr("[12345].Checked",'12345','1'));
    }

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

Related Tutorials