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
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Jan 12, 2008 7:45 pm   

%subregex bug
 
I have noticed that the use of ^ in the pattern of %subregex isn't quite fixed the way a user might expect. I am guessing that internally subregex breaks a string apart prior to passing it to the regex engine. This is done to move past the replaced portion, but the side effect of this method is that ^ can not be used to anchor to the beginning of the original string. An example of this
Code:
#SHOW %subregex("abcdefghijklmnop","^(.)","%pat(1)-")
You can see from the display that the dash is inserted after each character, the anchor does not work at all.

I would suggest that the solution to this is to not break the string apart, but to instead use a variable in the pattern to skip past the already matched portion. This method looks like
Code:
%regex($UserString,%concat("^.{",$lenMatched,"}",$UserPattern),...)
I am not exactly sure about the speed effect would have because I don't know exactly how the replacement is being done currently. I can say that a pattern of "^.{0}^" has no trouble matching to the start of the string. Meaning this change should not break any existing script and allows ^ in a user pattern to function properly.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
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