473,407 Members | 2,315 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,407 software developers and data experts.

need help with a "replace" function

Here's my code:

###
myvar = "test1_1;test2_1;test3_1";
myvar = myvar.replace(/_1/g, "_2")';
###

it works just fine. if I introduce "cat = 1", how do I change my
replace function so that instead of replacing a fixed "1" value, I
would use "cat"?

myvar = myvar.replace('/_'+cat'/g', "_2")' does not work.

Thanks!

Jul 9 '06 #1
1 1267
figured it out myself:

myvar = "test1_1;test2_1;test3_1";
cat = "1"
myregexp = new RegExp("_"+cat, "g")
myvar = myvar.replace(myregexp, "_2")';

:)
na************@msn.com wrote:
Here's my code:

###
myvar = "test1_1;test2_1;test3_1";
myvar = myvar.replace(/_1/g, "_2")';
###

it works just fine. if I introduce "cat = 1", how do I change my
replace function so that instead of replacing a fixed "1" value, I
would use "cat"?

myvar = myvar.replace('/_'+cat'/g', "_2")' does not work.

Thanks!
Jul 9 '06 #2

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

Similar topics

5
by: adrian zaharia | last post by:
Hello, Is it possible to use Replace function in a query against an excel file? I am trying this test code and gives me an error: Set cnnExcel = Server.CreateObject("ADODB.Connection")...
3
by: asd987 | last post by:
Hi, Can anyone tell me if "replace" is supported by Access 97? I use the Dutch version and get the errormessage "sub or function not supported". Or is the Professional Edition needed? Thanks.
3
by: Andy Sutorius | last post by:
Hi, I read the thread (2/16/05) regarding a replace function in C# however it didn't answer my question. I have a string which is building an insert sql statement and I would like to replace...
4
by: Lauren Wilson | last post by:
Hi folks, We have a need to replace sub strings in certain message text. We use the Office Assistant to display help and often use the imbedded formatting commands. Those of you who have used...
3
by: meendar | last post by:
Hi, Please find the below scenario Original Table course branch_exist BY 0 UI 1 PO 1
8
by: Warren Moxley | last post by:
Hi there, i've been searching for a C String search and replace function. I need to find all occurrences of " " in a char* array, and replace them with another char, I know how to do this in...
3
by: chriskaza81 | last post by:
helo all i have a string blablabla""blabla"" i want to make a space between two double qoates like blablabla" "blabla" " how can i do it in java .. i use replaceAll ...
1
by: seanmatthewwalsh | last post by:
Hi I have a website that uses an Access 2003 database. I have controls on my pages that are bound to SqlDataSources that pull data from this database. In a couple of them, I need to use the...
2
by: ArunDhaJ | last post by:
Hi, I'm having a DataTable with a column named "Phones" having value like (901) 789 1234<BR>(901) 789 1235<BR>(901) 789 1221 I need to perform filtering based on the phone number of the form...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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,...

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.