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
Daniel_Draco
Newbie


Joined: 08 Aug 2009
Posts: 8

PostPosted: Mon Jun 17, 2013 10:33 pm   

Regex Case Sensitivity
 
I have a need to remove all non-capitalized words from a list of words. As part of this I am using a regex to recognize which words begin with a capital letter -- and this is where it's failing. The problem can be demonstrated by inputting:
Code:
#say %regex("thisislowercase","[A-Z]\w+")
For me, this yields 1, indicating that a match was found, when it definitely should not; the [A-Z] should only match a capital letter. Is this issue unique to me? Is there any way to fix it?
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Tue Jun 18, 2013 2:00 am   
 
CMUD has the case insensitive option on by default. You can use (?-i) in your pattern to turn it off.
Reply with quote
Anaristos
Sorcerer


Joined: 17 Jul 2007
Posts: 821
Location: California

PostPosted: Tue Jun 18, 2013 2:55 am   
 
It seems that the default for CMUD regex is case insensitivity. Doing it this way works:
Code:

#SAY  %regex("thisislowercase","(?-i)[A-Z]\w+")

(?-i) turns case sensitivity on.
_________________
Sic itur ad astra.
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Tue Jun 18, 2013 3:46 am   
 
Umm... I thought I just said exactly that?
Reply with quote
Daniel_Draco
Newbie


Joined: 08 Aug 2009
Posts: 8

PostPosted: Tue Jun 18, 2013 5:43 am   
 
Aha, that worked, thanks. This doesn't appear to be anywhere in the documentation, for some reason -- in fact, the documentation of #REGEX implies that it is case sensitive by default.
Reply with quote
Moab
Beginner


Joined: 02 Aug 2008
Posts: 25

PostPosted: Tue Jun 18, 2013 5:10 pm   
 
Just ran into this myself.

Thanks!
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Wed Jun 19, 2013 5:19 pm   
 
Probably because CMUD doesn't have any extensive documentation on regular expressions. There's plenty of sites for that.
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