I would like to generate a regular expression that matches with a room description like this:
My Room Description(enter, n, s, e and w)
My Room Description(enter, e, s, w and n)
My Room Description(s, w, e, n and enter)
My Room Description(n, e, w, s and enter)
The exit directions could be in different position but will always be the same amount (4) in this case.
This should not match:
My Room Description(n, up, e, w, s and enter)
because it has 5 exits (other than “enter”).
Try this:
See live demo.
——-
To allow optional leading text, such as
"HP:245 EP:245 >> "as per your comment:Or more strict:
This restricts the leading characters to only those you’ve provided as an example. To allow anything: