|
-
Oct 22nd, 2001, 02:41 PM
#1
Thread Starter
Addicted Member
String Replace Method
I need to write a script that'll fnid a space, replace that space with a ` and then replace the ` with a ` and a space concatenated together. Now I tried finding a function in JavaScript that would allow me to do that but all I could find was some replace method that wants a regular expression as the first parameter. I found a good function in VBscript which allows Replace(string, replaceWhat, replaceWith) but I can't figure out how to call a VBScript from a JavaScript (I have never used VBScript before). Can anybody help out?
Thanks
-
Oct 22nd, 2001, 03:09 PM
#2
Frenzied Member
Guuuuurrttz.....
Uhm... no. Don't even bother with calling VBScript from JavaScript. And don't use VBScript in client side scripting. It is only supported by MS IE.
The second arguement of the VBScript Replace() function is the same as a Regular Expression.
Try something like this...
Code:
var myString;
myString.replace(/\s/g, " '");
I've never done this, and I have not tested this code.
As always, I recommend checking The Rhino.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Oct 22nd, 2001, 03:17 PM
#3
Thread Starter
Addicted Member
got it, I tested it out and it worked how I needed it to, thanks.
I'm not sure what all the /'s and \'s do but I guess I'll have to reference a site on regular expressions one day. but for now this gets the job done. thanks.
-
Oct 23rd, 2001, 01:33 AM
#4
Lively Member
I've had a simulair problem, but I solved it bij unescape / escape.
The replace function didn't work well enoguh for me.
the \ is an escape char
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|