473,320 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Space in REGEX in 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
May 9 '07 #1
13 1963
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

May 9 '07 #2
Lee
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>
--

May 9 '07 #3
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

May 10 '07 #4
Captain Paralytic <pa**********@yahoo.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...@invalid.invalidwrote:
Captain Paralytic <paul_laut...@yahoo.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.replace(/ /g,'');

with

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

then the error goes away.

May 10 '07 #6
Captain Paralytic <pa**********@yahoo.comwrote:
On 10 May, 15:06, Duncan Booth <duncan.bo...@invalid.invalidwrote:
>Captain Paralytic <paul_laut...@yahoo.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.replace(/ /g,'');

with

element.value = element.value.replace(/\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.javascript message <5a*************@mid.individual.net>,
Wed, 9 May 2007 21:01:44, Paul Lautman <pa**********@btinternet.com>
posted:
>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.
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.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
May 10 '07 #8
Duncan Booth wrote:
Captain Paralytic <pa**********@yahoo.comwrote:
>On 10 May, 15:06, Duncan Booth <duncan.bo...@invalid.invalidwrote:
>>Captain Paralytic <paul_laut...@yahoo.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.
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.replace(//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.javascript message <5a*************@mid.individual.net>,
Wed, 9 May 2007 21:01:44, Paul Lautman <pa**********@btinternet.com>
posted:
>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.
| 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
"Paul Lautman" <pa**********@btinternet.comwrote:
Lee's question was before his code. It was directly following the
quote of my post. Thus the question referred to my original post.
"Try the following" referred to your original post and not to the code
which followed it? Interesting use of words.
May 10 '07 #11
Duncan Booth wrote:
"Paul Lautman" <pa**********@btinternet.comwrote:
>Lee's question was before his code. It was directly following the
quote of my post. Thus the question referred to my original post.

"Try the following" referred to your original post and not to the code
which followed it? Interesting use of words.
Try the following was not a question. The question was "Does it work in
other browsers?"
The word "it" is a pronoun. The dictionary has this to say about it (no pun
intended):

(used to represent an inanimate thing understood, previously mentioned,
about to be mentioned, or present in the immediate context): It has
whitewall tires and red upholstery. You can't tell a book by its cover.

Note the words "previously mentioned". Thus the question referred to my
original post. My reply was to the question.

Simple really.

May 10 '07 #12
In comp.lang.javascript message <5a*************@mid.individual.net>,
Thu, 10 May 2007 19:16:30, Paul Lautman <pa**********@btinternet.com>
posted:
>Dr J R Stockton wrote:
>In comp.lang.javascript message <5a*************@mid.individual.net>,
Wed, 9 May 2007 21:01:44, Paul Lautman <pa**********@btinternet.com>
posted:
>>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.
| 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"
So your reading is careless too - the d key is nowhere near the y key.
>| 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.
Do you read a newspaper? probably. Do you read every word? probably
not.

With a good newsreader one can scan the Subject lines in a newsgroup
very rapidly, and one can quickly look at the articles too. I can
assess an article for probable interest in about a second and a half,
fairly reliably; quicker if it is by Randy. But you are using Outlook
Express.

You should, of course, read, heed and obey c.l.j FAQ section 2.3
sentence 1 before posting.

Knowing now what your problem was caused by : represent literal spaces
in RegExps with \x20 (the \ may need escaping) (or get the offending
software removed or corrected).

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQish topics, acronyms, & links.
For news:borland.*, use their server newsgroups.borland.com ; but first read
Guidelines <URL:http://www.borland.com/newsgroups/guide.htmlff. with care.
May 11 '07 #13
Dr J R Stockton wrote:
In comp.lang.javascript message <5a*************@mid.individual.net>,
Thu, 10 May 2007 19:16:30, Paul Lautman <pa**********@btinternet.com>
posted:
>Dr J R Stockton wrote:
>>In comp.lang.javascript message
<5a*************@mid.individual.net>, Wed, 9 May 2007 21:01:44,
Paul Lautman <pa**********@btinternet.composted:
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.

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"

So your reading is careless too - the d key is nowhere near the y key.
What are you on about? I accidentaly typed "and" instead of "an".
Or perhaps you think that
"However in IE6 it complained with any"Expected ')'" error."
is good grammar!
>
>>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.

Do you read a newspaper? probably. Do you read every word? probably
not.
And you say that I am careless in my writing!
With a good newsreader one can scan the Subject lines in a newsgroup
very rapidly, and one can quickly look at the articles too. I can
assess an article for probable interest in about a second and a half,
fairly reliably; quicker if it is by Randy. But you are using Outlook
Express.
And of course I did this, but bearing in mind the obscure cause of my
problem I did not find anything.
You should, of course, read, heed and obey c.l.j FAQ section 2.3
sentence 1 before posting.
As of course should you. The bit about quoting springs to mind.
But now I suddenly notice that the part about rudeness was of course written
with you in mind.
It's a good job that most people who frequent newsgroups are decent helpful
people. Stick around and you just might pick some of it up.

May 12 '07 #14

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

Similar topics

12
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...
6
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
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. *...
2
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...
3
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(" ",...
16
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. ...
1
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...
4
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...
5
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...
8
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.