Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Sat Sep 29, 2007 4:45 pm   

[2.04] Can't use pipes (|) within {braces} in trigger pattern to match nothing
 
This is a new bug in v2.04.

I've reduced the trigger pattern to:
you ({|asking |exclaiming })

"you asking " matches but "you " does not. This feature (matching nothing) is very useful to capture optional text for #SUBs.

Win XP SP2
Reply with quote
Thinjon100
Apprentice


Joined: 12 Jul 2004
Posts: 190
Location: Canada

PostPosted: Sat Sep 29, 2007 5:44 pm   
 
If you write it in regex you can do it, I think... try:

you ({asking|exclaiming}?)

With the regular expression box checked.
_________________
If you're ever around Aardwolf, I'm that invisible guy you can never see. Wizi ftw! :)
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Sat Sep 29, 2007 6:27 pm   
 
Well, the point of beta testing is to find bugs not workarounds! Wink

But I might give it a go anyway.
Reply with quote
Thinjon100
Apprentice


Joined: 12 Jul 2004
Posts: 190
Location: Canada

PostPosted: Sat Sep 29, 2007 6:28 pm   
 
Aye, this I know... but I figured it wouldn't hurt to offer a tangible solution as well :)
_________________
If you're ever around Aardwolf, I'm that invisible guy you can never see. Wizi ftw! :)
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Sat Sep 29, 2007 6:35 pm   
 
Ah, I've found the actual bug: CMUD is generating the incorrect regular expression. It's not adding the | at the end:

CMUD v2.03:
you (asking |exclaiming |)
CMUD v2.04:
you (asking |exclaiming )

This is from the Test Pattern tab, where you can see the perl regex it is actually using.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sat Sep 29, 2007 6:51 pm   
 
Optional text and wildcards inside {these|things} are normally the two tipping points where I use a regex instead of a normal trigger. Thinjon's almost right - the proper regex is (asking|exclaiming)?.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Sat Sep 29, 2007 6:55 pm   
 
Is (asking |exclaiming )? more efficient then (asking |exclaiming |)?

Note that words are usually followed by spaces, and always in this case, so I have to match a space too when there is a word there.
Reply with quote
Thinjon100
Apprentice


Joined: 12 Jul 2004
Posts: 190
Location: Canada

PostPosted: Sat Sep 29, 2007 6:59 pm   
 
My apologies, Fang... forgot my parenthesis-brace discrimination... I always do that. :P

In your case, Seb, I'd recommend:
you\s((asking|exclaiming)\s)?

Unless I've slipped on my syntax again, this should read "capture the word 'asking' or 'exclaiming' followed by a single space, or nothing at all, after the word 'you' followed by a space.

There MAY be a necessity for a non-capture syntax in there, I'm not certain... but in that case I think it'd be:
you\s((?:asking|exclaiming)\s)?
_________________
If you're ever around Aardwolf, I'm that invisible guy you can never see. Wizi ftw! :)
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sat Sep 29, 2007 7:03 pm   
 
There's probably not a great deal of difference, since the regex moves from left to right through the possible options until one matches. The last one there matches (because it's empty), but the regex still has to go through the possibilities first. In the other one, the regex tries all the possibilities, but if none match, it carries on anyway.

I just hate how (some|thing|) looks - like you made a typo or missed an option out - especially when there's only one optional string.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Mon Oct 01, 2007 5:52 pm   
 
bug confirmed and added to bug list
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net