[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]  regex help
Home  |  Users  |  Search  |  FAQ
Register forum user name
Forgotten password?

regex help

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Posted by Fletchling   Australia  (54 posts)  [Biography] bio
Date Tue 08 Aug 2006 12:55 PM (UTC)
Hi ho, I have the following problem. I can do this thing but I want to see an elegant solution, as you'll see my regex's are a bit agricultural.

mud input below;

Level: 3 Shield Mana: 5 Learned: 100% ( 72)
Mental barrier Mana: 5 Learned: 100% (126)

my regex to match this is in this trigger;

<send>ArrayCreate ("su4")
if %4 &gt; 72 then
ArraySet ("su4",(string.lower(Trim("%2"))),"0")
end -- if

The issue is that it only matches the first line (with shield) and I'd like it to match either case, that being the line that starts with Level: or without Level:, but I'd like to do it properly. The regex expression I've worked just plain looks ugly, I'm sure there's a better way.

This thing is part of my fast spell up script for aardwolf mud and works a treat, but I have to add some spells manually to the array (via an alias) which is fine but My crash test dummy objects to the extra effort, as she should.

As always, thanks for the help.

[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] bio
Date Reply #1 on Tue 08 Aug 2006 01:52 PM (UTC)
This probably isn't any prettier, but it should work:

[Go to top] top

Posted by Fletchling   Australia  (54 posts)  [Biography] bio
Date Reply #2 on Wed 09 Aug 2006 10:06 AM (UTC)
Ked, thanks!
That worked first go, nice!

If you ever have any annoying slimes you need killed, just send the word.
[Go to top] top

Posted by Nick Gammon   Australia  (21,669 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Wed 09 Aug 2006 10:10 PM (UTC)
In fact, with regular expressions, you can use the "optional thing" syntax on not just letters (eg. [A-Z]{0,1} ) which will match an optional letter in the range A-Z but entire groups, like this:


This will match 'blahsomething' or just 'something'.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[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.     [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.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

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

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]