LookBehind issue at beginning of document

SyntaxEditor for Windows Forms Forum

Posted 13 years ago by Benjamin Lewis
Avatar
The following pattern group is incorrectly matching the first word in my document:

<RegexPatternGroup TokenKey="AliasToken" Style="AliasStyle" PatternValue="{AlphaMacro} {WordMacro}*" LookBehind="as {WhitespaceMacro}+" />

If I have a document that begins with, say, the line "var foo : int;", the word "var" is being highlighted in AliasStyle, as if the LookBehind had instead been written LookBehind="^ | as {WhitespaceMacro}*". If I prepend a single space, highlighting works properly.

[update]: I meant, of course, that the LookBehind is behaving like
LookBehind="\A | as {WhitespaceMacro}*" (beginning of document, rather than beginning of line).

Thanks,
--
Benjamin Lewis

[Modified at 06/27/2006 02:47 PM]

Comments (6)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
This is a known issue with the regex engine. Right now it has to consume at least one character to match on a LookAhead or LookBehind. So since the start of document specification is a zero-width assertion, the match fails. It's on the TODO list... we have to dig into our regex engine to try and change the code so that this is permitted.


Actipro Software Support

Posted 13 years ago by Benjamin Lewis
Avatar
My problem is not that the match is failing, it's that the match is NOT failing when it should be. The LookBehind (LookBehind="as {WhitespaceMacro}+") is evaluating to TRUE at the beginning of the document when it should not be.

--
Benjamin Lewis

[Modified at 06/27/2006 06:32 PM]
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Yes you are correct, I forgot about that. We had made it evaluate to true as a workaround to the problem I stated since more often than not, the LookAhead/LookBehind are true at a document start. However in your case it was not. So once we change how the regex engine works, it will resolve this.


Actipro Software Support

Posted 13 years ago by Joris Koster - Paragon Decision Technology
Avatar
We would also be very happy when the 'look-behind at beginning of document' issue is solved; any estimates on when this bug is going to be fixed?
Thanks!
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
This issue is now fixed for v4.0. Zero-length look-ahead and look-behinds are now supported.


Actipro Software Support

Posted 13 years ago by Benjamin Lewis
Avatar
Glad to hear it; I'll refrain from asking the next obvious question...
The latest build of this product (v2018.1 build 0341) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.