js 대체 문자열 의 모든 예제 코드

1190 단어 js 교체문자열
 
/**
*
* @param obj
* @param str1
* @param str2
* @return
*/
function replaceAll(obj,str1,str2){
var result = obj.replace(eval("/"+str1+"/gi"),str2);
return result;
}
예 를 들 어
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script type="text/javascript">
function replaceAll(obj,str1,str2){
var result = obj.replace(eval("/"+str1+"/gi"),str2);
return result;
}
alert(replaceAll("111,222,333",",","|"));
</script>
</head>
<body>
</body>
</html>

좋은 웹페이지 즐겨찾기