473,320 Members | 1,961 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.

Simple replace question

Hi, I want to replace all occurences of this ),( in my string with a comma
.....

statement=statement.replace("),(",",");

This only does the first. I've been reading about adding "/g", but haven't
got it to work. I've messed about with no luck. Any quick pointers? Thanks.
Feb 20 '06 #1
2 979
I think you need to use

statement = statement.replace( /\),\(/g , "," )

Because the first argument to replace should be enclosed with / rather
than quotes and you need to prefix brackets in regexp's with \ 'cause
brackets have a special meaning in regular expressions

Feb 20 '06 #2

"tihu" <ti********@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
I think you need to use

statement = statement.replace( /\),\(/g , "," )

Because the first argument to replace should be enclosed with / rather
than quotes and you need to prefix brackets in regexp's with \ 'cause
brackets have a special meaning in regular expressions


Thanks, I thought I'd tried that combination. Hmm, well it works great,
thanks.

Feb 20 '06 #3

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

Similar topics

9
by: C L Humphreys | last post by:
Hi, I'm used to programming with Java, and am unsure of how this may work within VB. I want to pass some strings to a function, and alter them within the function. I want the strings to stay...
5
by: SteveB | last post by:
However, despite being simple, I can't figure it out (maybe because I'm a newbie). I'm trying to replace a string with another string, but it simply is not working (no error messages, just won't...
7
by: dan | last post by:
hey peeps, i am completely new at c++ and i need some help with an assignment. it is basically about file i/o with fstreams. i understand how to open a file with fstream, but how would you read,...
1
by: timothy ma and constance lee | last post by:
Sir I have the simple question as follows: I got three pages a,b,c point to same page d when clicking submit. Is there any way, by using JavaScript to trace back which page a or b or c to...
6
by: wl | last post by:
Hi, I'm relatively new to Javascript and wanted to use the split function to split a string into an array. I need to split on every single occurence of = and &. For example:...
9
by: Not Me | last post by:
Hi, I'm having bother with the replace function in access 2002, a while back I remember not being able to get it to work... then suddenly the next time I tried it did work. Now it doesn't...
3
by: Howard Dean | last post by:
I have a string with several carriage returns in it. For example: "This is my test string" I wish to convert it to "This is my test string" (remove all carriage returns. Can someone tell me...
3
by: P2000 | last post by:
I want to make a regex for the replace function that will replace any "a" with "A" and any "b" with "B". This is what I did so far... (I'm trying to learn this RegEx thing) <form> <input...
4
by: SM | last post by:
Hello, I have a simple question, but can't find the answer. I have a string that contains a path to a file I want to add another string to the end of that string So, if i have : path =...
9
by: vedrandekovic | last post by:
Hello, I have one question about string.I am trying to make an function to analyze line of some text, this is my example: "HELLO;HELLO2:WORLD:", if that function in this text find ";" and ":" (...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.