Advertisement
honghoavi

Replace Function - vi du

Nov 24th, 2015
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // VD1
  2. <script type='text/javascript'>var myString = ‘Blog Thiet Ke talks about Thiet Ke blog';alert(myString.replace('Thiet Ke', 'design'));
  3. //output : "Blog design talks about Thiet Ke blog" . Not "blog design talks about design blog".</script>
  4.  
  5. // VD2
  6. <script type='text/javascript'>var myString = ‘Blog Thiet Ke talks about Thiet Ke blog';alert(myString.replace(/Thiet Ke/g, "design"));
  7. //output : "Blog design talks about design blog"</script>
  8.  
  9. // VD3
  10. <script type='text/javascript'>var myString = ‘Blog Thiet Ke talks about Thiet Ke blog';alert(myString.replace(/thiet ke/gi, "design"));
  11. //output : "Blog design talks about design blog"</script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement