Welcome to the Achaea Forums! Please be sure to read the Forum Rules.

Regex for "Who"

Calamus Member Posts: 5
edited July 2013 in Tech Support
Hey everyone,

I'm lookin for some help with regex to capture a specific target's location when I type the "who" command while using echinacea.

This is difficult on two fronts, I think.

First, I can't figure out how to capture an undefined amount of multiple words before my "target's" name. Second, once my trigger sees that name, I then need it to skip an undefined amount of words and then capture whatever their location is (which I think would be handled by saying "capture everything between the parentheses").

For those who don't know the line, it's something like this:

xxxx xxxx xxxx (yyyy yyyy yyy)

Where the name can be any one of the xxxx words (and there can be more or less words over there) then there's a big group of spaces followed by parentheses with the targets location (again with any number of words)

Edit: the spaces won't save in between my X and Y example, but there's supposed to be a big block of space there.

It should also take into account a potential (Phased) tag before the xxxx's if a target is phased.


  • Orzaansyn
    Orzaansyn Member Posts: 663 @@ - Legendary Achaean
    edited July 2013
    It seems tricky, for some people have another aventurer's name in their name. There are several Disciple of Orzaansyn, for exemple.

    but you have 2 different captures:
    1 to capture the adventurer's name in the WHO list
    1 to capture the place of the adventurer.

     Second difficulty then: when someone's location is not available, nothing shows, depending on your client's possibilities you may therefore get the location of the next adventurer in the list instead of detecting a line break.

    I'll think about it this night.
  • Calamus
    Calamus Member Posts: 5
    Oh man, I didn't even think about duplicate names, chameleons or missing locations... thanks for bringing those up too.

    Also, I'm using mudlet, if that's any help.
  • Sena
    Sena Member Posts: 3,957 @@ - Legendary Achaean
    I don't have access to my scripts right now to see the actual regex I use (I can get that later if it's still needed), but you can look at the "who search" script in the site in my signature for an example that works in most cases. It's a zMUD script but the regex should be the same. The relevant triggers (there are two) are near the bottom of the script.
  • Josoul
    Josoul Member Posts: 131 ✭✭✭ - Distinguished
    For the first part I'd suggest you to check WHO B(RIEF) instead of WHO list, it skips titles leaving just the names. 
  • Eld
    Eld Member Posts: 3,946 @@ - Legendary Achaean
    edited July 2013
    Yeah, WHO B is definitely easier, as it doesn't require distinguishing names from the surrounding titles. If, for some reason, you really want to do it with the full WHO, you can distinguish the name from the rest of the title by color. @Sena's zMUD script does this by using the ANSI color escapes in the regex. If you happen to be using Mudlet, that won't work (since Mudlet's regex triggers run on just the text instead of the raw ANSI stream, if I understand correctly), but you can do it with a multiline trigger along the lines of:

    pattern 0 (regex): ^
    pattern 1 (color): foreground - cyan, background - black
    pattern 2 (regex): (\w+)
    pattern 3 (color): foreground - white, background - black
    pattern 4 (regex): \((.+)\)$

    with the multiline/AND box checked, and line delta set to 0. In that case, multimatches[3][2] would be the person's name and multimatches[5][2] would be the room. That will, of course, only pick up people whose names are in cyan, so it will skip Romeo and Juliet, and anyone else with differently coloured names that shows up on WHO (can't remember if gods/demigods/etc do or not).
  • Antonius
    Antonius Member Posts: 5,040 @@ - Legendary Achaean
    I think Gods, etc probably do, but you're not likely to be able to determine their location anyway so it doesn't really matter.
  • Adet
    Adet Member Posts: 273 ✭✭✭✭ - Eminent
    Bear in mind also that a simple text pattern for location will also miss out locations with "(House)" at the beginning, and "(Road)" or "(Indoors)" at the end (if they show - I can't remember).
  • Eld
    Eld Member Posts: 3,946 @@ - Legendary Achaean
    edited July 2013
    Adet said:
    Bear in mind also that a simple text pattern for location will also miss out locations with "(House)" at the beginning, and "(Road)" or "(Indoors)" at the end (if they show - I can't remember).
    The \((.+)\) I used will match (house) locations. And no, (road) and (indoors) do not show up on WHO.
  • Adet
    Adet Member Posts: 273 ✭✭✭✭ - Eminent
    Ah, okay.  I am (as is evident) not a regexpert.

    Is regexpert a legitimate term?  It feels like it should be.
Sign In to Comment.