I play a mud using mudlet and wish to use Perl regex to capture some input from my prompt. The thing is it seems really hard to do without being overly repetitive in my search. I'm hoping to come up with an elegant solution to
Here is my sample prompt line: [NESWDNeSeSwNw] [The Palace Square-Bastion] [|Excl] >)|61|(<
What I want to capture is the list of directions where each direction begins with an uppercase letter and may or may not contain a lower case letter (in case of diagonals only). Valid upper letters are N E S W U D (cardinal indicators) and the valid lowercase letters are e w only (diagonal indicators)
I was trying to use something to the effect of: ^.([NESWUD]{1}[ew]?)+.
(dots to match the brackets since brackets seem to be incapable of being escaped in the pcre that mudlet uses for triggers)
The problem with this solution is that it does not capture all the directions and the greedy matching matches the last directon "Nw
" only. If I break it down to remove the capture group and the greediness to just [NESWUD]{1}[ew]?
it gives me the every occurance of the capital letters everywhere not just in my prompt.
Any help would be greatly appreciated.