I thought that this would be the right regex to capture this information, but its not working...Shrine of Eliatha [ne].
So, I'm not sure what I'm doing wrong here.
Artty
I thought that this would be the right regex to capture this information, but its not working...Shrine of Eliatha [ne].
Code: Select all
^(.*?)\s+\[([A-z]+)\]\.$
Code: Select all
^(.*?) \[(.*?)\]$
Heh, that is a VERY handy website for visuallising RegEx. I also use http://regexpal.com/ for testing.Vadi wrote:Now that is a great website.
I'm assuming you're trying to match a room short desc + exits.WillFa wrote:\w is any letter (any word character). It doesn't match spaces.
^(.*?) \[(.*?)\]$
is what you want.
There could very well be more information within the [ ]'s , however the OP simply asked for a RegEx that would match on the line given. It states nothing more about requiring capture or parsing of additional text, or tests.robg wrote:I'm assuming you're trying to match a room short desc + exits.WillFa wrote:\w is any letter (any word character). It doesn't match spaces.
^(.*?) \[(.*?)\]$
is what you want.
Of the posted responses, this is the best one. It backtracks less, and unlike the others, will actually not break if there's more than one exit. I can't speak to the mud you play, but the one I play has some occasionally bizarre exits that [a-z,]+ wouldn't match, so better to be safe than sorry. Although to be fair, I'd probably make the [] section optional so that it can match if there are no obvious exits as well, and use some kind of ansi match to recognize that it's a room (server dependant).
You will do fine in life if you listen to what people say.Rakon wrote:There could very well be more information within the [ ]'s , however the OP simply asked for a RegEx that would match on the line given. It states nothing more about requiring capture or parsing of additional text, or tests.robg wrote:I'm assuming you're trying to match a room short desc + exits.WillFa wrote:\w is any letter (any word character). It doesn't match spaces.
^(.*?) \[(.*?)\]$
is what you want.
Of the posted responses, this is the best one. It backtracks less, and unlike the others, will actually not break if there's more than one exit. I can't speak to the mud you play, but the one I play has some occasionally bizarre exits that [a-z,]+ wouldn't match, so better to be safe than sorry. Although to be fair, I'd probably make the [] section optional so that it can match if there are no obvious exits as well, and use some kind of ansi match to recognize that it's a room (server dependant).
Ask, and you shall receive!