473,574 Members | 2,884 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Space in REGEX in IE6

I was using the following code:

element.value = element.value.r eplace(/ /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
May 9 '07 #1
13 1983
On May 9, 4:01 pm, "Paul Lautman" <paul.laut...@b tinternet.comwr ote:
I was using the following code:

element.value = element.value.r eplace(/ /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

May 9 '07 #2
Lee
Paul Lautman said:
>
I was using the following code:

element.valu e = element.value.r eplace(/ /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>
--

May 9 '07 #3
On 9 May, 23:00, Lee <REM0VElbspamt. ..@cox.netwrote :
PaulLautmansaid :
I was using the following code:
element.value = element.value.r eplace(/ /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

May 10 '07 #4
Captain Paralytic <pa**********@y ahoo.comwrote:
On 9 May, 23:00, Lee <REM0VElbspamt. ..@cox.netwrote :
>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
Fails how?

It works in a completely clean IE6 installation (tested using Microsoft
Virtual PC and Microsoft's own IE6 XP image, copy/pasting the exact text
Lee posted).
May 10 '07 #5
On 10 May, 15:06, Duncan Booth <duncan.bo...@i nvalid.invalidw rote:
Captain Paralytic <paul_laut...@y ahoo.comwrote:
On 9 May, 23:00, Lee <REM0VElbspamt. ..@cox.netwrote :
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

Fails how?

It works in a completely clean IE6 installation (tested using Microsoft
Virtual PC and Microsoft's own IE6 XP image, copy/pasting the exact text
Lee posted).- Hide quoted text -

- Show quoted text -
I think you have misread the conversation!

I said, that I had an error and I specified that error as "Expected
')'"

Lee posted asking "Does it work in other browsers?".

I answered this question by saying that "It works in IE7 and Firefox,
but fails in IE6"

You then said "Fails how?"

I now refer you back to my first post where I said "However in IE6 it
complained with an "Expected ')'" error.", which answers you question
of "Fails how?", before you even asked it! Phew!!

Lee's suspicion was a problem elsewhere in my code. However it all
works fine in both IE7 and FF. If I replace

element.value = element.value.r eplace(/ /g,'');

with

element.value = element.value.r eplace(/\s/g,'');

then the error goes away.

May 10 '07 #6
Captain Paralytic <pa**********@y ahoo.comwrote:
On 10 May, 15:06, Duncan Booth <duncan.bo...@i nvalid.invalidw rote:
>Captain Paralytic <paul_laut...@y ahoo.comwrote:
On 9 May, 23:00, Lee <REM0VElbspamt. ..@cox.netwrote :
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

Fails how?

It works in a completely clean IE6 installation (tested using Microsoft
Virtual PC and Microsoft's own IE6 XP image, copy/pasting the exact text
Lee posted).- Hide quoted text -

- Show quoted text -

I think you have misread the conversation!
Perhaps, but not obviously.
>
I said, that I had an error and I specified that error as "Expected
')'"

Lee posted asking "Does it work in other browsers?".
No, Lee said "Try the following in IE6. It works for me in IE7 and
Firefox" and posted a minimal example. I assumed that your response was
referring to the reduced example not the original page.
>
I answered this question by saying that "It works in IE7 and Firefox,
but fails in IE6"

You then said "Fails how?"

I now refer you back to my first post where I said "However in IE6 it
complained with an "Expected ')'" error.", which answers you question
of "Fails how?", before you even asked it! Phew!!
I understood that your original code fails with "Expected ')'", but I
wanted to know how Lee's reduced example fails for you in IE6.
>
Lee's suspicion was a problem elsewhere in my code. However it all
works fine in both IE7 and FF. If I replace

element.value = element.value.r eplace(/ /g,'');

with

element.value = element.value.r eplace(/\s/g,'');

then the error goes away.
Great, but to the best of my knowledge IE6 has no problems with the first
form either.
May 10 '07 #7
In comp.lang.javas cript message <5a************ *@mid.individua l.net>,
Wed, 9 May 2007 21:01:44, Paul Lautman <pa**********@b tinternet.com>
posted:
>I was using the following code:

element.valu e = element.value.r eplace(/ /g,'');

to remove all the spaces in a string.

However in IE6 it complained with and "Expected ')'" error.
It works in IE6 (and FF2). Perhaps your code is no more carefully
written than your article?

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v6.05 IE 6
news:comp.lang. javascript FAQ <URL:http://www.jibbering.c om/faq/index.html>.
<URL:http://www.merlyn.demo n.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
May 10 '07 #8
Duncan Booth wrote:
Captain Paralytic <pa**********@y ahoo.comwrote:
>On 10 May, 15:06, Duncan Booth <duncan.bo...@i nvalid.invalidw rote:
>>Captain Paralytic <paul_laut...@y ahoo.comwrote:
On 9 May, 23:00, Lee <REM0VElbspamt. ..@cox.netwrote :
Try the following in IE6. It works for me in IE7 and Firefox:

<html>
<body>
<script type="text/javascript">
alert("Hell o there, world".replace(/ /g,''));
</script>
</body>
</html>

--

It works in IE7 and Firefox, but fails in IE6

Fails how?

It works in a completely clean IE6 installation (tested using
Microsoft Virtual PC and Microsoft's own IE6 XP image, copy/pasting
the exact text Lee posted).- Hide quoted text -

- Show quoted text -

I think you have misread the conversation!

Perhaps, but not obviously.
>>
I said, that I had an error and I specified that error as "Expected
')'"

Lee posted asking "Does it work in other browsers?".

No, Lee said "Try the following in IE6. It works for me in IE7 and
Firefox" and posted a minimal example. I assumed that your response
was referring to the reduced example not the original page.
Lee's question was before his code. It was directly following the quote of
my post. Thus the question referred to my original post.

However, I have now discovered what the problem actually was.

The offending code was a line in an event script for the Facile Forms
component of Mambo/Joomla. It worked fine on my machine but failed when I
sent it off to someone else and they put it on their site.

Unfortunately their site is on an intranet and so the only way I could view
it was via a VPN and then with Microsoft Remote Desktop Connection. The
browser on their server was IE6 and so I assumed that the problem was with
IE6.

However (again), Facile Forms has an option for compressing JavaScript and
HTML and this was set on their site, but not on mine.

The facile forms compress function doesn't handle regular expressions in the
scripts very well and it was stripping out the space and thus leaving the
line as:
element.value = element.value.r eplace(//g,'');

Thanks for all the support and ideas folks. If it hadn't been for your
assurances, I would never had bothered to look as deeply as I did.
May 10 '07 #9
Dr J R Stockton wrote:
In comp.lang.javas cript message <5a************ *@mid.individua l.net>,
Wed, 9 May 2007 21:01:44, Paul Lautman <pa**********@b tinternet.com>
posted:
>I was using the following code:

element.valu e = element.value.r eplace(/ /g,'');

to remove all the spaces in a string.

However in IE6 it complained with and "Expected ')'" error.
| It works in IE6 (and FF2). Perhaps your code is no more carefully
| written than your article?
Ahh abuse, very helpful.
Pray tell, where precisely was my article "careless"

| It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
What??? Read the newsgroup? All of it? You have to be joking. I always
google a group before asking a question, but there is no way I could read
all of the group.

May 10 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
14694
by: lawrence | last post by:
I'm bad at regular expressions. Is this how I would look for any set of characters that go more than 60 characters without a white space? ..{60} Also, does this match a block of PHP in an HTML page:
6
2420
by: Xah Lee | last post by:
how to represent the unicode "em space" in regex? e.g. i want do something like this: fracture=re.split(r'\342371*\|\342371*',myline,re.U) Xah xah@xahlee.org ∑ http://xahlee.org/
5
33289
by: Alex Vassiliev | last post by:
Hi all. Just wanted to share two handy RegEx expressions to strips leading and trailing white-space from a string, and to replace all repeated spaces, newlines and tabs with a single space. * JavaScript example: String.prototype.trim = function() { // Strip leading and trailing white-space
2
5062
by: José Joye | last post by:
Hello, I was wondering if there is a method that exists to replace multi-spaces within a string with single-space. eg: "12 3 4 56" --> "12 3 4 56" I think this could be done by looking at each char within a loop and copying the char to a stringBuilder instance if current and previous char are not spaces...
3
19625
by: Julie | last post by:
I currently use the following to remove embedded spaces from strings: dest = str.Replace(" ", ""); and resort to something like the following to remove white space: dest = str.Replace(" ", "").Replace("\t", "").etc.; Is there a better, more efficient way?
16
8241
by: simonc | last post by:
One of the things that drives me mad about vb.net is spending time trying to make a program do something then finding that there's already an inbuild procedure that does exactly the same thing. So before I begin on this can anyone tell me if there is already a routine to do this: I am dividing up a delimited textstring using...
1
1680
by: Guoqi Zheng | last post by:
Dear sir, I am using .NET tcpClient to connect to remote POP server. When I get the string from server response, the string always contains many white space. I think the ReceiveBufferSize is always too big, it seems to me that server always response with a fix buffer size, but send the response stream in 3 times. I tried to get rid of...
4
3182
by: whisher | last post by:
Hi. I'm taking my first steps on regex I set up this simple function to check if a form field is empty or with only space. var onlySpaceRegexp = /^\s*$/; function isEmpty(val) { if (onlySpaceRegexp.test(val) || val == "") {
5
3478
by: Johny | last post by:
How can I find the first space using regex? For example I have text Text=' This is a sample ' The last space I can remove by Text=re.sub(r"\s(?!\w)",'',Text) but I do not know how to remove the first space. Can anyone help?
8
2056
by: =?Utf-8?B?TTFpUw==?= | last post by:
I’m trying to parse out Amazon S3 server logs which are space delimited. However date fields are in the following form: When I try to use the following code to split the record on the spaces it also splits date field: string fields = record.Split(' ');
0
7753
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8095
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7847
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6500
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5332
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3769
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3787
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1365
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1096
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.