how do i replace this text? |
Author: |
Message: |
roflmao456
Skinning Contest Winner
   

Posts: 955 Reputation: 24
30 / / 
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 |
|
 |
markee
Veteran Member
    

Posts: 1622 Reputation: 50
36 / / 
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  )
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.
|
|
11-21-2006 02:59 AM |
|
 |
roflmao456
Skinning Contest Winner
   

Posts: 955 Reputation: 24
30 / / 
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 
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 |
|
 |
markee
Veteran Member
    

Posts: 1622 Reputation: 50
36 / / 
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).
|
|
11-21-2006 03:12 AM |
|
 |
roflmao456
Skinning Contest Winner
   

Posts: 955 Reputation: 24
30 / / 
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 |
|
 |
markee
Veteran Member
    

Posts: 1622 Reputation: 50
36 / / 
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).
|
|
11-21-2006 03:37 AM |
|
 |
roflmao456
Skinning Contest Winner
   

Posts: 955 Reputation: 24
30 / / 
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 |
|
 |
TazDevil
Full Member
  

sleep(0);
Posts: 359 Reputation: 11
41 / / 
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 |
|
 |
Matti
Elite Member
    

Script Developer and Helper
Posts: 1646 Reputation: 39
32 / / 
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");
|
|
12-01-2006 04:16 PM |
|
 |
TazDevil
Full Member
  

sleep(0);
Posts: 359 Reputation: 11
41 / / 
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 |
|
 |
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|