[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  regexp: match multiple consecutive whole words on the same line
Home  |  Users  |  Search  |  FAQ
Register forum user name
Forgotten password?
(New message)
Subject: regexp: match multiple consecutive whole words on the same line
Your forum user name.
Register forum user name
Your forum password.
Forgotten password?
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...

Subject review (reverse sequence)

Posted by Missingl   (2 posts)  [Biography] bio
Date Sun 16 Jul 2006 02:21 PM (UTC)  quote  ]
thanks guys,

that was a little too easy for you, i'm kinda embarrassed. Nonetheless, what you suggested worked perfectly shadowfyr, thank you.

Also thanks for the link Nick, looking through the forums i missed it. i'll be sure to have a look at it thoroughly.


[Go to top] top

Posted by Nick Gammon   Australia  (19,666 posts)  [Biography] bio   Forum Administrator
Date Sat 15 Jul 2006 09:50 PM (UTC)  quote  ]
My forum post about regular expressions explains in quite a bit of detail:


Shadowfyr is right, you want an "assertion" (which does not actually consume characters) rather than a match.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Shadowfyr   USA  (1,776 posts)  [Biography] bio
Date Sat 15 Jul 2006 07:18 PM (UTC)  quote  ]

Amended on Sat 15 Jul 2006 07:19 PM (UTC) by Shadowfyr

Umm.. Well, the reason for this is simple. You're telling it to do this:

string = " on on one "
Search 1 = " on on one "
            ^  ^
Search 2 = "on one "
              ^   ^

Where ^ is where it finds the start and end of the next "match".

In other words, since you are specifically looking for the space, its incrementing the point where it starts looking again "past" that space. This should fix it (uses no spaces):


The explaination given in Mushclient's documentation is from one of those horrible, "If you are reading this, you should understand what I mean.", documents you often get in the world of "professionals", who all speak Computer Nerd. Apparently I need to take a course on it, since I can't comprehend half the more obscure stuff in the Regexp documents. lol

Just to make sure I was understanding it though, I googled for a better explaination:


"\b" is basically an assertion that the following match "must" have one character on either side be a \w (letter), while the other "must" be a \W (spaces, newline, etc.). It does not include the characters it finds in what it returns, so it should only match the word itself, meaning that the next search will start with the space following the word it found.

main {
__if (Schrodinger_Cat is Alive or version >= "XP"){
____if version = "Vista" then Performance /= Number_of_Cores;
____call Functional_Code();}
____call Crash_Windows();}
[Go to top] top

Posted by Missingl   (2 posts)  [Biography] bio
Date Sat 15 Jul 2006 02:44 PM (UTC)  quote  ]
Hi all,

i'd like to write some regular expressions which match whole (specified) words on a line. For example, the string:

You feel weaker as the power of the Strength spell wanes.

i wish to filter (mark / change colour of) all instances of:

now if i use " (you|as|the|of|one|on) ", (with keep evaluating and repeat on same line ticked) if two matching words occur next to each other, it only matches the first. if another word matches further down the string, however, it matches ok.

the reason for the spaces on either side of the regexp is so it matches the entire word. i don't want it to match, for example, the "the" in "these", and therefore mark half the word.

of course one could capture all the words in the line, and parse it via script, and cause the output to popup else where, but i think speedwise the trigger only would be a tad quicker.

finally, awesome client, best i've come across yet, excellent work Nick.

thanks for any help.

[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


It is now over 60 days since the last post. This thread is closed.   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum

[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.


Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Web site powered by FutureQuest.Net]