What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » how do i replace this text?

Pages: (2): « First [ 1 ] 2 » Last »
how do i replace this text?
Author: Message:
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
30 / Male / Flag
Joined: Nov 2006
Status: Away
O.P. how do i replace this text?
ok i need help in how to replace this text like

EX. :

i type:   lol (!SM)

then it ends up when i send it:

John says: lol Sup Mate




how do i do that?
[quote]
Ultimatess6
: What a noob mod
11-21-2006 02:55 AM
Profile PM Web Find Quote Report
markee
Veteran Member
*****

Avatar

Posts: 1622
Reputation: 50
36 / Male / Flag
Joined: Jan 2006
RE: how do i replace this text?
You can either use this code that I did (using regular expressions) or you could use something like answering machine+(I realise this wasn't the right thing :P)
code:
var Sup = /\(\!SM\)/gi;
function OnEvent_ChatWndSendMessage(wnd,msg){
    msg = msg.replace(Sup,"Sup Mate");
    return msg;
}


This post was edited on 11-21-2006 at 03:13 AM by markee.
[Image: markee.png]
11-21-2006 02:59 AM
Profile PM Find Quote Report
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
30 / Male / Flag
Joined: Nov 2006
Status: Away
O.P. RE: how do i replace this text?
ty il try that

edit: is it possible to replace a normal strand of text like

i type: LoL this

to replace "this" in what i type

then it will turn up like

John says: LoL hello

lol im alittle noob on this "replacing stuff" but im good at everything else :P

This post was edited on 11-21-2006 at 03:02 AM by roflmao456.
[quote]
Ultimatess6
: What a noob mod
11-21-2006 02:59 AM
Profile PM Web Find Quote Report
markee
Veteran Member
*****

Avatar

Posts: 1622
Reputation: 50
36 / Male / Flag
Joined: Jan 2006
RE: how do i replace this text?
I suggest you look up how to do regular expressions, they help outheaps.  For just a basic string (using just letters or numbers assymbols can have a different meaning) then you can use my code as anexample and put the likes of the following

code:
var replace1 = /text/gi;
function ...(...){
    string = string.replace(replace1,"text to replace it with");
}
For symbols like / \ . * $ ^ + ?  etc then you will need to prefix those characters with \

There are a heap more thing involved in regular expressions but those few things will get you started (though I suggest you try learning more).
[Image: markee.png]
11-21-2006 03:12 AM
Profile PM Find Quote Report
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
30 / Male / Flag
Joined: Nov 2006
Status: Away
O.P. RE: RE: how do i replace this text?
quote:
Originally posted by markee
I suggest you look up how to do regular expressions, they help outheaps.  For just a basic string (using just letters or numbers assymbols can have a different meaning) then you can use my code as anexample and put the likes of the following

code:
var replace1 = /text/gi;
function ...(...){
    string = string.replace(replace1,"text to replace it with");
}
For symbols like / \ . * $ ^ + ?  etc then you will need to prefix those characters with \

There are a heap more thing involved in regular expressions but those few things will get you started (though I suggest you try learning more).


it doesn't seem i can use that with OnEvent_ChatWndReceiveMessage or OnEvent_ChatWndSendMessage... it works now...

im just making a script right now that will change some words into this using a list. how can i do that .....????


EDIT: like say

a list of words like this:

hello
hi
whatever
hey

changed into

sup
yo
w/e
hay

This post was edited on 11-21-2006 at 03:57 AM by roflmao456.
[quote]
Ultimatess6
: What a noob mod
11-21-2006 03:25 AM
Profile PM Web Find Quote Report
markee
Veteran Member
*****

Avatar

Posts: 1622
Reputation: 50
36 / Male / Flag
Joined: Jan 2006
RE: how do i replace this text?
You can do this all in one long line
code:
[...]
string = string.replace(/hello/gi,"sup").replace(/hi/gi,"yo").replace(/whatever/gi,"w/e").replace(/hey/gi,"hay");
[...]


You can do these all individually  and you can set the regular expressions as variables like I did before, but why bother if you only have a small list like this.  Unfortunately I don't think it is possible to use a for count and an array so you will have to keep changing the script itself (though if anyone can prove me wrong I will be appreciative).
[Image: markee.png]
11-21-2006 03:37 AM
Profile PM Find Quote Report
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
30 / Male / Flag
Joined: Nov 2006
Status: Away
O.P. RE: how do i replace this text?
thanks so much i hope this will help other people viewing this
[quote]
Ultimatess6
: What a noob mod
11-21-2006 04:14 AM
Profile PM Web Find Quote Report
TazDevil
Full Member
***

Avatar
sleep(0);

Posts: 359
Reputation: 11
41 / Male / Flag
Joined: May 2004
RE: how do i replace this text?
and how can i check if it is the actual word and not part of the word

eg. teh is replaced by the but the function should not replace tehn with then

t-h combination is what i type wrong most of the times...
thanks

This post was edited on 12-01-2006 at 04:10 PM by TazDevil.
Window Manager is discontinued, for WLM try the new,
Enhancer for contact list docking, auto-hide, hide taskbar button, remove button flashing and remember keyboard layout in conversation windows
12-01-2006 04:08 PM
Profile PM Web Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: how do i replace this text?
Use regular expressions! ;)
code:
var nMessage = Message.replace(/(^|\s|\n)teh($|\s|\n)/gi, "$1the$2");
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
12-01-2006 04:16 PM
Profile E-Mail PM Web Find Quote Report
TazDevil
Full Member
***

Avatar
sleep(0);

Posts: 359
Reputation: 11
41 / Male / Flag
Joined: May 2004
RE: how do i replace this text?
quote:
Originally posted by Mattike
/(^|\s|\n)teh($|\s|\n)/gi, "$1the$2"
thanks,
you are a life saver, it would have taken ages to compile that string expression ;)

no more spelling mistakes in chat then :)
Window Manager is discontinued, for WLM try the new,
Enhancer for contact list docking, auto-hide, hide taskbar button, remove button flashing and remember keyboard layout in conversation windows
12-01-2006 04:23 PM
Profile PM Web 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