|
 |
asp_web_howto thread: ASP scripting in JavaScript
Message #1 by "Brian" <bgmst5@y...> on Wed, 21 Mar 2001 15:58:53
|
|
Hello,
Instead of using the default language for ASP, i want to use JavaScript.
However, I am not sure how i can do string manipulation. I basically want
to use the replace function in vbscript, but some of the functionality of
the page doesn't work so well in vbscript or i would change over.
What i want to do is convert a value of "Full Name Group"
to "Full_Name_Group".
Does anybody know how to?
Thanks,
Brian Mains
Message #2 by "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> on Wed, 21 Mar 2001 16:07:55 -0000
|
|
you'll have to write your own replace function
use the indexOf method to find the value, then use the substr method to chop
off everything that precedes it, and store in one variable, and again to
chop off everything that comes after it, and stor in another variable. Then
create a new string by appending the two strings with the new value
inbetween them. If you're going to have multiple occurances, then you'll
need to have some kind of loop as well.
-----Original Message-----
From: Brian [mailto:bgmst5@y...]
Sent: Wednesday, March 21, 2001 3:59 PM
To: ASP Web HowTo
Subject: [asp_web_howto] ASP scripting in JavaScript
Hello,
Instead of using the default language for ASP, i want to use JavaScript.
However, I am not sure how i can do string manipulation. I basically want
to use the replace function in vbscript, but some of the functionality of
the page doesn't work so well in vbscript or i would change over.
What i want to do is convert a value of "Full Name Group"
to "Full_Name_Group".
Does anybody know how to?
Thanks,
Brian Mains
Message #3 by "Peter Lanoie" <planoie@e...> on Mon, 26 Mar 2001 09:00:38 -0500
|
|
1. Create a JavaScript regular expression
2. Use the string.replace method with that regular expression
var strMyString = "Full Name Group";
var regMySearchRegX = /_/gi; // find all instances of whatever's between the
two /
strMyString = strMyString.replace(regMySearchRegX, "_"); //replace the ones
found with _
Now strMyString = "Full_Name_Group"
-----Original Message-----
From: Alex Shiell, ITS, EC, SE [mailto:alex.shiell@s...]
Sent: Wednesday, March 21, 2001 11:08 AM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: ASP scripting in JavaScript
you'll have to write your own replace function
use the indexOf method to find the value, then use the substr method to chop
off everything that precedes it, and store in one variable, and again to
chop off everything that comes after it, and stor in another variable. Then
create a new string by appending the two strings with the new value
inbetween them. If you're going to have multiple occurances, then you'll
need to have some kind of loop as well.
-----Original Message-----
From: Brian [mailto:bgmst5@y...]
Sent: Wednesday, March 21, 2001 3:59 PM
To: ASP Web HowTo
Subject: [asp_web_howto] ASP scripting in JavaScript
Hello,
Instead of using the default language for ASP, i want to use JavaScript.
However, I am not sure how i can do string manipulation. I basically want
to use the replace function in vbscript, but some of the functionality of
the page doesn't work so well in vbscript or i would change over.
What i want to do is convert a value of "Full Name Group"
to "Full_Name_Group".
Does anybody know how to?
Thanks,
Brian Mains
|
|
 |