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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
ReedN
Wizard


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

PostPosted: Sat Feb 03, 2007 10:01 pm   

Regex can't detect a [ at the beginning of a line
 
Is there some problem with detecting a "[" at the beginning of a line? I tried the following without any success:

Regex:
^[

-Reed
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sat Feb 03, 2007 10:27 pm   
 
[ is a special character, it needs escaping with \ to create:

Code:
^\[whatever


EDIT: Actually, that's not working either. I tried that regex, echoing [whatever manually and it wouldn't fire.
Reply with quote
ReedN
Wizard


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

PostPosted: Sun Feb 04, 2007 12:39 am   
 
I must have made a typo, because I meant to type a "\" before the [. So I meant that even with escaping the character it didn't work... which I thought was odd.
Reply with quote
ReedN
Wizard


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

PostPosted: Sun Feb 04, 2007 1:14 am   
 
Okay, so it sounds like Fang is seeing the same issue that I am if I'm understanding his edit correctly. The issue being that even when the brace is escaped it doesn't fire.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Sun Feb 04, 2007 5:25 am   
 
I did some playing around with this and it seems tied to an issue with the parser looking for a closing bracket.

I tested with these triggers.

#REGEX {Test} {#show A Works}
#REGEX {[Test]} {#show B works}
#REGEX {[Test} {#show C works}

#SHOW "[Test] this"
#SHOW "[Test this"
#SHOW "[Test this] as well"

The first show command will fire all 3 triggers, the second and third show commands will only fire the first trigger.

[Edit] The problem holds true even if its not at the beginning of a line.
_________________
Asati di tempari!
Reply with quote
ReedN
Wizard


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

PostPosted: Sun Feb 04, 2007 8:31 am   
 
Well I'm glad this could be verified and that I wasn't doing something dumb to cause it.
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Sun Feb 04, 2007 11:38 pm   
 
Here, as well--having a single (quoted) [ anywhere failed, having matched []s or a single ] works fine.

Having a single unquoted [ was treated like there was an invisible closing (unquoted) ] at the end.
Reply with quote
Zugg
MASTER


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

PostPosted: Mon Feb 05, 2007 8:12 pm   
 
Tech: aren't you missing some \ characters in your #REGEX patterns? I know that the forum bbcode will convert \ [ into just [ so maybe that was the problem. I think if you put it within a [code] bbcode tag then it won't strip them.

In any case, the [ *is* a special regular expression character. It is used to specify character ranges. So you *must* put a \ character before the [ in your pattern for anything to make sense.

I'm assuming that you used the \ and it was just the forums that messed up the post, because when I tried your examples and had the correct \ in front of each [ then it still failed just as you mentioned. So I've added this to the bug list.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Tue Feb 06, 2007 12:40 am   
 
Yes I did use the \ before the [. I didn't even notice that they got stripped.
_________________
Asati di tempari!
Reply with quote
ReedN
Wizard


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

PostPosted: Tue Feb 06, 2007 1:03 am   
 
Ah, so I'm not going crazy, I did have it there and the forum stripped it without me noticing. I felt like an idiot when I looked back it wasn't escaped and I thought I had escaped it.

I did have a "\" before the "[" because I knew that braces are special characters for character ranges.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion 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