Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: 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. |
|