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?

how do i replace this text?
Author: Message:
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?
quote:
Originally posted by markee
Why use such a complex regular expression when you can do the same by this.

code:
var nMessage = Message.replace(/teh/gi, "the");

This will do exactly the same thing as what your regular expression did except it is smaller and less confusing for those that are new to regular expressions.
You should've read his question twice:
quote:
Originally posted by TazDevil
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
He wants to have "teh" replaced, but not "tehn". With your simpler expression, it'll replace all occurrences of "teh", including "tehn". With my somewhat complexer expression, it'll only replace when:
  • "teh" is at the begin of the string OR preceded by a space or newline AND
  • "teh" is at the end of the string OR proceeded by a space or newline.
When it matches, it'll also re-add the captured spaces and newline characters to keep the remaining string intact. ;)
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:33 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
how do i replace this text? - by roflmao456 on 11-21-2006 at 02:55 AM
RE: how do i replace this text? - by markee on 11-21-2006 at 02:59 AM
RE: how do i replace this text? - by roflmao456 on 11-21-2006 at 02:59 AM
RE: how do i replace this text? - by markee on 11-21-2006 at 03:12 AM
RE: RE: how do i replace this text? - by roflmao456 on 11-21-2006 at 03:25 AM
RE: how do i replace this text? - by markee on 11-21-2006 at 03:37 AM
RE: how do i replace this text? - by roflmao456 on 11-21-2006 at 04:14 AM
RE: how do i replace this text? - by TazDevil on 12-01-2006 at 04:08 PM
RE: how do i replace this text? - by Matti on 12-01-2006 at 04:16 PM
RE: RE: how do i replace this text? - by markee on 12-01-2006 at 04:25 PM
RE: how do i replace this text? - by TazDevil on 12-01-2006 at 04:23 PM
RE: how do i replace this text? - by TazDevil on 12-01-2006 at 04:31 PM
RE: how do i replace this text? - by Matti on 12-01-2006 at 04:33 PM
RE: how do i replace this text? - by TazDevil on 12-01-2006 at 04:52 PM
RE: how do i replace this text? - by markee on 12-01-2006 at 05:08 PM
RE: how do i replace this text? - by CookieRevised on 12-01-2006 at 09:02 PM
RE: how do i replace this text? - by TazDevil on 12-01-2006 at 09:44 PM


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