What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » "Style"

Pages: (2): « First « 1 [ 2 ] Last »
"Style"
Author: Message:
wlmcrap
Junior Member
**

Avatar
David

Posts: 71
Reputation: -6
30 / Male / –
Joined: Jul 2006
O.P. RE: "Style"
Yep! Here you go.

.plsc File Attachment: Style.plsc (1015 bytes)
This file has been downloaded 165 time(s).
07-13-2006 01:28 AM
Profile E-Mail PM Web Find Quote Report
ddunk
Veteran Member
*****

Avatar

Posts: 1228
Reputation: 51
35 / Male / Flag
Joined: Mar 2004
RE: "Style"
quote:
Originally posted by wlmcrap
Yep! Here you go.
That will only replace the first occurence.
quote:
Originally posted by Joereynolds89
i got most of it from another forum, i just have the problem of having it repeat, for example i get A by putting a but if i put aaa i get Aaa if that makes sense?
You need to use regexps if you want to do that.
See:
Pai's reply to [Help] Replacing Text Using Scripts (I think I'm dumb lol)
and
segosa's reply to [Help] Replacing Text Using Scripts (I think I'm dumb lol)

This post was edited on 07-13-2006 at 01:40 AM by ddunk.
07-13-2006 01:37 AM
Profile E-Mail PM Web Find Quote Report
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
Joined: Jan 2006
RE: "Style"
Not really. You can use the String.replace function with a loop.
code:
function replace(s,from,to){
    while (s.indexOf(from) > -1){
        s = s.replace(from,to);
    }
    return s;
}

Then you can say:
code:
var StringToReplace = 'aaaaaaaa';
StringToReplace = replace(StringToReplace,'a','A');
07-13-2006 01:42 AM
Profile PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: "Style"
quote:
Originally posted by deAd
Not really. You can use the String.replace function with a loop.
Although you indeed can, it is also a bit useless to do that. One should indeed use the regular expression syntax for replacing all occurences of a search string. This is even documented like that in the official MS JScript references. ;)


PS: your example code for the loop will produce wrong results in certain cases. And actually shows why you should not use a loop like that to replace all occurences of a string.

This post was edited on 07-13-2006 at 09:42 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
07-13-2006 09:39 AM
Profile PM Find Quote Report
Pages: (2): « First « 1 [ 2 ] Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On