IE6中的REGEX空间 [英] Space in REGEX in IE6
问题描述
我使用的是以下代码:
element.value = element.value.replace(/ / g,'''');
删除字符串中的所有空格。
然而在IE6中,它抱怨和预期'''''错误。
如何告诉IE6只替换空格(即不使用\)?
我试过/ \ /和/ [] /但他们都没有工作。
TIA
5月9日,下午4:01,Paul Lautman < paul.laut ... @ btinternet.comwrote:
我使用以下代码:
元素。 value = element.value.replace(/ / g,'''');
删除字符串中的所有空格。
然而,在IE6中它抱怨和预期')''错误。
如何告诉IE6只替换空格(即不使用\)?
我试过/ \ /和/ [] /但他们都没有工作。
现在没有IE6可用,但请尝试/ \x20 /
----
Geoff
Paul Lautman说:
> <我正在使用以下代码:
element.value = element.value.replace(/ / g,'''');
删除所有字符串中的空格。
然而在IE6中它抱怨和预期'''''错误。
它在其他浏览器中有效吗?
我首先怀疑你的代码中的其他地方有问题。 />
在IE6中尝试以下操作。在IE7和Firefox中它适用于我:
< html>
< body>
< script type = " text / javascript">
alert(" Hello there,world" .replace(/ / g,''''));
< /脚本>
< / body>
< / html>
-
5月9日23:00,Lee< REM0VElbspamt ... @ cox.netwrote:
PaulLautmansaid:
< blockquote class =post_quotes>
我使用以下代码:
element.value = element.value.replace(/ / G,'''');
删除字符串中的所有空格。
然而在IE6中,它抱怨和预期'''''错误。
它在其他浏览器中有效吗?
我的第一个怀疑是你的代码中的其他地方出了问题。 />
在IE6中尝试以下操作。在IE7和Firefox中它适用于我:
< html>
< body>
< script type = " text / javascript">
alert(" Hello there,world" .replace(/ / g,''''));
< /脚本>
< / body>
< / html>
-
它适用于IE7和Firefox,但在IE6中失败
I was using the following code:
element.value = element.value.replace(/ /g,'''');
to remove all the spaces in a string.
However in IE6 it complained with and "Expected '')''" error.
How can I tell IE6 to replace just spaces (i.e. not using \s)?
I tried /\ / and /[ ]/ but neither of them worked either.
TIA
On May 9, 4:01 pm, "Paul Lautman" <paul.laut...@btinternet.comwrote:I was using the following code:
element.value = element.value.replace(/ /g,'''');
to remove all the spaces in a string.
However in IE6 it complained with and "Expected '')''" error.
How can I tell IE6 to replace just spaces (i.e. not using \s)?
I tried /\ / and /[ ]/ but neither of them worked either.Don''t have IE6 available right now, but try /\x20/
----
Geoff
Paul Lautman said:>
I was using the following code:
element.value = element.value.replace(/ /g,'''');
to remove all the spaces in a string.
However in IE6 it complained with and "Expected '')''" error.Does it work in other browsers?
My first suspicion is that you''ve got a problem elsewhere in your code.
Try the following in IE6. It works for me in IE7 and Firefox:
<html>
<body>
<script type="text/javascript">
alert("Hello there, world".replace(/ /g,''''));
</script>
</body>
</html>
--
On 9 May, 23:00, Lee <REM0VElbspamt...@cox.netwrote:PaulLautmansaid:
I was using the following code:
element.value = element.value.replace(/ /g,'''');
to remove all the spaces in a string.
However in IE6 it complained with and "Expected '')''" error.
Does it work in other browsers?
My first suspicion is that you''ve got a problem elsewhere in your code.
Try the following in IE6. It works for me in IE7 and Firefox:
<html>
<body>
<script type="text/javascript">
alert("Hello there, world".replace(/ /g,''''));
</script>
</body>
</html>
--It works in IE7 and Firefox, but fails in IE6
这篇关于IE6中的REGEX空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!