更新时间:2023-02-23 14:53:55
2006年12月1日13: 41:10 -0800,在comp.lang.javascript al****@gmail.com
< 11 ********************* @ j72g2000cwa.googlegroups。 comwrote:
On 1 Dec 2006 13:41:10 -0800, in comp.lang.javascript al****@gmail.com
<11*********************@j72g2000cwa.googlegroups. comwrote:
> |有人可以告诉我如何最忠实地做这件事吗?.....
|
|我有一个文本框,我想搜索它的内容并替换
|某个单词的所有实例,并用某些东西替换该单词
|其他。出于此目的,它可以替换绿色。与
| "蓝色" ;.有人可以告诉我如何正确地做到这一点? :)
|
|真诚的问候,Alxasa。
>| Hi, can someone please show me how to most elegently do this?.....
|
| I have a textbox, and I want to search the contents of it and replace
| all instances of a certain word, and replace that word with something
| else. For the purposes of this it could be replacing "green" with
| "blue". Can someone please show me how to properly do this? :)
|
| Sincerest regards, Alxasa.
< SCRIPT>
re = / apples / gi;
str ="苹果是圆形的苹果很多汁。;
newstr = str.replace(re,oranges);
document.write(newstr)
< / SCRIPT>
---------------------------------- -----------------------------
jn ****** @ yourpantsyahoo.com.au :脱掉裤子回复
-------------- -------------------------------------------------
<SCRIPT>
re = /apples/gi;
str = "Apples are round, and apples are juicy.";
newstr=str.replace(re, "oranges");
document.write(newstr)
</SCRIPT>
---------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
Jeff North写道:
Jeff North wrote:
2006年12月1日13:41: 10 -0800,在comp.lang.javascript al****@gmail.com
< 11 ********************* @ j72g2000cwa.googlegroups。 comwrote:
On 1 Dec 2006 13:41:10 -0800, in comp.lang.javascript al****@gmail.com
<11*********************@j72g2000cwa.googlegroups. comwrote:
|有人可以告诉我如何最忠实地做这件事吗?.....
|
|我有一个文本框,我想搜索它的内容并替换
|某个单词的所有实例,并用某些东西替换该单词
|其他。出于此目的,它可以替换绿色。与
| "蓝色" ;.有人可以告诉我如何正确地做到这一点? :)
|
|真诚的问候,Alxasa。
| Hi, can someone please show me how to most elegently do this?.....
|
| I have a textbox, and I want to search the contents of it and replace
| all instances of a certain word, and replace that word with something
| else. For the purposes of this it could be replacing "green" with
| "blue". Can someone please show me how to properly do this? :)
|
| Sincerest regards, Alxasa.
< SCRIPT>
re = / apples / gi;
str ="苹果是圆的苹果很多汁。;
newstr = str.replace(re,oranges);
document.write(newstr)
< / SCRIPT>
---------------------------------- -----------------------------
jn ****** @ yourpantsyahoo.com.au :脱掉裤子回复
-------------- -------------------------------------------------
<SCRIPT>
re = /apples/gi;
str = "Apples are round, and apples are juicy.";
newstr=str.replace(re, "oranges");
document.write(newstr)
</SCRIPT>
---------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
:)你能告诉我如何做同样的事情来实现
textarea吗?
< ; textarea id = sunny cols = 25>苹果是圆的,苹果是
多汁。< / textarea>
< SCRIPT>
re = / apples / gi;
str ="苹果是圆的,苹果很多。;
newstr = str.replace( re,oranges);
document.write(newstr)
< / SCRIPT >
:) Could you pls show me how to do that same thing to effect a
textarea?
<textarea id=sunny cols=25>Apples are round, and apples are
juicy.</textarea>
<SCRIPT>
re = /apples/gi;
str = "Apples are round, and apples are juicy.";
newstr=str.replace(re, "oranges");
document.write(newstr)
</SCRIPT>
2006年12月1日17:24:21 -0800,在comp.lang.javascript中 al **** @ gmail.com
< 11 ******************* ***@l12g2000cwl.googlegroups .comwrote:
On 1 Dec 2006 17:24:21 -0800, in comp.lang.javascript al****@gmail.com
<11**********************@l12g2000cwl.googlegroups .comwrote:
> | Jeff North写道:
| 2006年12月1日13:41:10 -0800,在comp.lang.javascript al****@gmail.com
| < 11 ********************* @ j72g2000cwa.googlegroups。 comwrote:
| >
| |有人可以告诉我如何最忠实地做到这一点吗?.....
| |
| |我有一个文本框,我想搜索它的内容并替换
| |某个单词的所有实例,并用某些东西替换该单词
| |其他。出于此目的,它可以替换绿色。与
| | "蓝色" ;.有人可以告诉我如何正确地做到这一点? :)
| |
| |真诚的问候,Alxasa。
| >
| < SCRIPT>
| re = / apples / gi;
| str ="苹果是圆的,苹果很多。;
| newstr = str.replace(re,oranges);
| document.write(newstr)
| < / SCRIPT>
|
| :)你能不能告诉我如何做同样的事情来实现
| textarea的?
>| Jeff North wrote:
| On 1 Dec 2006 13:41:10 -0800, in comp.lang.javascript al****@gmail.com
| <11*********************@j72g2000cwa.googlegroups. comwrote:
| >
| | Hi, can someone please show me how to most elegently do this?.....
| |
| | I have a textbox, and I want to search the contents of it and replace
| | all instances of a certain word, and replace that word with something
| | else. For the purposes of this it could be replacing "green" with
| | "blue". Can someone please show me how to properly do this? :)
| |
| | Sincerest regards, Alxasa.
| >
| <SCRIPT>
| re = /apples/gi;
| str = "Apples are round, and apples are juicy.";
| newstr=str.replace(re, "oranges");
| document.write(newstr)
| </SCRIPT>
|
| :) Could you pls show me how to do that same thing to effect a
| textarea?
<!DOCTYPE html PUBLIC" - // W3C // DTD XHTML 1.0 Strict // EN"
" http: //www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
< html xmlns =" http://www.w3.org/1999/xhtml" ;>
< head>
< meta http-equiv =" Content-Type"含量=" text / html的;字符集= UTF-8英寸/>
< title> Untitled Document< / title>
< script type =" text / javascript">
function ReplaceApples()
{
// ---设置正则表达式字符串
re = / apples / gi;
// ---- get element
id = document.getElementById(" sunny");
// ---获取元素中的文字
str = id.value;
// ---做正则表达式替换
newstr = str.replace(re," oranges");
// ---将新值保存回元素
id.value = newstr;
}
< ; / script>
< / head>
< body>
< textarea id =" sunny" cols = 25>苹果是圆的,苹果是
多汁。< / textarea>
< input name =" btn"类型= QUOT按钮" onclick =" ReplaceApples()"
value =" Change" />
< / body>
< / html>
------------- --------------------------------------------------
jn******@yourpantsyahoo.com.au :脱掉裤子回复
------------------------------------------- --------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function ReplaceApples()
{
//--- setup regex string
re = /apples/gi;
//---- get element
id = document.getElementById("sunny");
//--- get text within element
str = id.value;
//--- do regex replace
newstr=str.replace(re, "oranges");
//--- save new value back to element
id.value = newstr;
}
</script>
</head>
<body>
<textarea id="sunny" cols=25>Apples are round, and apples are
juicy.</textarea>
<input name="btn" type="button" onclick="ReplaceApples()"
value="Change" />
</body>
</html>
---------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------