Locating & echoing - perl regex

Post Reply
Posts: 7
Joined: Fri Mar 20, 2015 9:35 am

Locating & echoing - perl regex

Post by Narnai »


I'm trying to use Locating & echoing functions from the Mudlet mapper, but I'm having issues guessing the right perl regex to capture the rooms.

The thing logs like this:
Name - Room name [in/or empty]Area name [number]

Which would, lets say, look like this:

Bob - Bob's kitchen [in]Bob's house [1]
Bobo - Bob's living room [in]Bob's house [1]
Rob - Bob's garden [ ]Bob's house [2]
Tom - Bob's garden [ ]Bob's house [2]

I came up with this:
(.+)\- (.+?\s*?)\[(.+)](.+)\[(\d+)]

Now, that seems to be capturing *some*, sometimes, and the mapper's script manages to echo the room numbers off of it.

(Not sure it matters, but the amount of whitespace characters between the room name and [in/empty] ranges from a lot to one - depending on the length of the room name.)

Any help would be appreciated, thanks!

User avatar
Posts: 999
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Locating & echoing - perl regex

Post by SlySven »

You will need to escape all four of the '[' and ']' - not just the '['s with a '\' - as they are both special characters to the regex engine unless told that they are not...

Post Reply