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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Trigger matching problem

Trigger matching problem

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


Posted by Henry Tanner   Finland  (23 posts)  [Biography] bio
Date Sat 30 Apr 2011 04:43 AM (UTC)
Message
I have a trigger match line set up as "^*\s\s*\s\s*\s\s\d$" without quotes and for some reason it's not picking up what I'm trying to pick up with it:
Coruscant       Coruscant Sector      The Galactic Republic     100.0
Kashyyyk        Mytaranor Sector      Neutral Government        100.0
Lorrd           Kanz Sector           The Galactic Republic     100.0
Corellia        Corellian System      The Galactic Republic     100.0
Korriban        Horuset System        The Sith Empire           100.0
Tatooine        Tatoo System          The Sith Empire           100.0
Wroona          Wroona System         Neutral Government        100.0
Arkania         Perave System         The Sith Empire           100.0
Ryloth          Ryloth System         The Sith Empire           100.0
Dantooine       Raioballo Sector      Neutral Government        100.0
Alderaan        Alderaan System       The Galactic Republic     100.0
Nal Hutta       Hutt Space            Neutral Government        3.0
Ziost           Ziost System          Neutral Government        100.0


I can't see where I'm doing it wrong

I got this!
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #1 on Sat 30 Apr 2011 07:20 AM (UTC)

Amended on Sat 30 Apr 2011 07:22 AM (UTC) by Twisol

Message
Hmm...
^*\s\s*\s\s*\s\s\d$

This literally means "Zero or more start-of-string positions, a space, zero or more spaces, a space, zero or more spaces, a space, another space, and a digit, followed by the end-of-string position. In other words, you're matching a string with at least four spaces plus a single digit. That's not what you want.

The problem is that you're mixing the non-regex pattern's * capture into a regular expression, where * mean's a totally different thing ("zero or more"). What you really want is this:

^[A-Za-z]+\s+[A-Za-z ]+\s+[A-Za-z ]+\s+(\d+\.\d+)$


This is a lot more verbose (clearly), but it should match the example lines given. I had to use (\d+\.\d+) to match the number at the end, because \d only matches a digit (0 through 9).

[EDIT]: Alternatively, if you can be certain that this trigger will only be active when these lines are being processed, you can use the far simpler (\d+\.\d+)$

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Sat 30 Apr 2011 12:25 PM (UTC)
Message
Henry Tanner said:

I have a trigger match line set up as "^*\s\s*\s\s*\s\s\d$" without quotes and for some reason it's not picking up what I'm trying to pick up with it:


You don't have that, because it is not a valid regular expression, it won't accept it:


Nothing to repeat.

^*\s\s*\s\s*\s\s\d$
^

Error occurred at column 2.


So maybe you don't have regular expressions ticked? In which case that explains a lot.

- Nick Gammon

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

Posted by Henry Tanner   Finland  (23 posts)  [Biography] bio
Date Reply #3 on Tue 03 May 2011 07:55 PM (UTC)

Amended on Tue 03 May 2011 08:00 PM (UTC) by Henry Tanner

Message
Twisol's match line works but I'll need to pull the information in to variables:
 Planet          Starsystem            Governed By               Popular Support
Coruscant       Coruscant Sector      The Galactic Republic     100.0 


I need to get the planet, starsystem, governed and popular support.

also there's a line in the beginning of the output and in the end of the output that I can use to enable and disable the trigger...

so how can I get it to work with wildcards?

EDIT: that came out very confusing, so I'm trying to get everything from under the different columns to (after running them through a string.gsub to kill spaces) tables

I got this!
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #4 on Tue 03 May 2011 09:37 PM (UTC)
Message
()'s around what you want to capture:
^([A-Za-z]+)\s+([A-Za-z ]+)\s+([A-Za-z ]+)\s+(\d+\.\d+)$


As for the begin/end lines, I'm guessing they're pretty much static, so you can use a non-regex trigger and paste the whole line in.
Planet          Starsystem            Governed By               Popular Support

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[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.


15,502 views.

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.

[Home]


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 HostDash]