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
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Wed Mar 19, 2008 4:40 am   

[2.20] Matching of blank line with regex not working in some cases
 
The only way I can get a regex to match on a blank line is with:

^$

Nothing else works, including the following which I can't tell why it doesn't work:

^\s*$

I put them into triggers to test and I executed:

#show ""

The first will match, the second will not.
Reply with quote
Zugg
MASTER


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

PostPosted: Wed Mar 19, 2008 8:26 pm   
 
This is because blank lines are trapped specially by CMUD to avoid calling the full regular expression library. CMUD will only look for a specific ^$ pattern to match a blank line. I don't see where this would be a problem though.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Mar 19, 2008 11:06 pm   
 
This was actually spawned by a discussion in the General Forum. The user there wishs to preform a match like "^(First|Second)?$". In other words a trigger consilidation where a few possibilities are expected at a given time and a blank line is one of those possibilities.

I suddenly thought to myself as long as the regex engine is being bypassed, why not check it just once. This would mean that after a trigger is compiled test a match with a blank line, and if it comes back with a match then record that. Then when you go to skip the regex engine later you can check the recorded flag, and if it is true then a match is signaled.

I also don't really think this bypass is needed. I can only see if being helpful if you place such triggers in a seperate list so that only a few triggers are looped through for enabled and scope checks. I am pretty sure the regex engine handles the blank line in a very optimal fashion.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Thu Mar 20, 2008 12:20 am   
 
I have a total of about half a dozen cases where I want to send a command to the Mud in a background type of fashion. I'll capture the lines, process them, and #gag them so they aren't visible. This is typically done to check some state or confirm something that doesn't need to be visible to me and in fact would be visually disruptive. In nearly every single one of these cases the sending of a command and the reception of feedback will generate extra blank lines. I'd like to just have one trigger so I can catch all the input with just one trigger to either process it or gag it. As it is now I can't ever combine these blank line triggers with anything else which means I'll always have to enable multiple triggers to handle this or I have to enable a class with two triggers.
Reply with quote
Zhiroc
Adept


Joined: 04 Feb 2005
Posts: 246

PostPosted: Thu Mar 20, 2008 5:20 am   
 
Please don't do something like this, it just confuses the heck out of people. Just pass blank lines to the regex library. I can't imagine there's that many, and checking blank lines against non-blank patterns must be really fast anyways.
Reply with quote
Zugg
MASTER


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

PostPosted: Fri Mar 21, 2008 4:58 pm   
 
OK, I'll add this to the to-do list. This actually came over when I ported the trigger parsing from zMUD to CMUD since this optimization used to matter more in zMUD before PCRE was being used.
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