javascript中的text.replace [英] text.replace in javascript

查看:94
本文介绍了javascript中的text.replace的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨所有



i有一个大字符串包含一个单词Year / Make,我想将其替换为阿拉伯语单词,但是当我试图使用text.replace,第一部分Make仅被替换,Year仍然是原样。



可以任何人帮助我这个语法请...



谢谢

解决方案

此测试

 i =  年/制 
o = i.replace( 年/制 < span class =code-string> foo)
alert(o)



输出:

 foo 



(我用这个 [ ^ ])。


我也是使用了CPa使用的相同链接llini使用以下代码并且工作正常。但是,输出并不完全相同。但我猜测它必须对我的本地Internet Explorer设置做些什么。所以你应该试试这个:



 i =年/制
o = i.replace(年/制造, الطراز/الموديل);
alert(o);






试试这个:

 text = text.split( 年/制作). join  الطراز/الموديل ); 


hi all

i have a big string contains a word as "Year/Make" and i would like to replace it to be in Arabic word , but when i tried to use text.replace , the first part "Make" that was replaced only and "Year" still as it is .

can any one helps me in this syntax please...

thanks

解决方案

This test

i = "Year/Make"
o = i.replace("Year/Make", "foo")
alert(o)


outputs:

foo


(I used this[^]).


I also used the same link used by CPallini with the following code and it worked. However, the output was not exactly the same. But it''s my wild guess that it has to do something with my local settings of the internet explorer. So you should try this:

i = "Year/Make"
o = i.replace("Year/Make","الطراز/الموديل");
alert(o);


Hi,

Try this:

text = text.split("Year/Make").join("الطراز/الموديل");


这篇关于javascript中的text.replace的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆