javascript_정규 표현 식 \용법

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<HEAD>  
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>javascript(\b)test</TITLE>  
     
</HEAD>  
  
<BODY >  
    "\b"      ,            ,               。  
    <br>  
    String str="winawin a win window aswin"  
    <ul>      
  <li id="test_id1" onclick="leftB()" >leftB  .</li>      
  <li id="test_id2" onclick="rightB()">rightB  .</li>      
  <li id="test_id3" onclick="allB()">allB  .</li>      
  <li id="test_id4" onclick="noB()">noB  .</li>      
  </ul>
<script language="JavaScript" type="text/javascript">      
  var str = "winawin a win window aswin"    
  function leftB()     
  {
   document.getElementById("test_id1").innerHTML=str.replace(/\bwin/g,"lose");     
  }       
  function rightB()     
  {      
      document.getElementById("test_id2").innerHTML=str.replace(/win\b/g,"lose");   
  }        
  function allB()     
  {      
   document.getElementById("test_id3").innerHTML=str.replace(/\bwin\b/g,"lose");      
  }      
  function noB()     
  {      
   document.getElementById("test_id4").innerHTML=str.replace(/win/g,"lose");      
  }     
  </script>      
</BODY>  
</HTML>  

좋은 웹페이지 즐겨찾기