RegexPatternGroup Problem...

SyntaxEditor for Windows Forms Forum

Posted 15 years ago by rconde01
Avatar
Hi,
I have two problems related to regex parsing in the syntax editor.

1) I use the following regex:

<RegexPatternGroup Token="ObjectTypeWordToken" PatternValue="While\s*\(.*\)" Style="ObjectTypeKeyWord" IsWhitespace="True" CaseSensitivity="Sensitive" />

Which should match "While (sdsdf)" - minus the quotes. I've confirmed this using a dotnet regex tester. But the syntax editor doesn't seem to like a variable string between parentheses.

2) If I change the PatternValue to "While\s*\(.*?\)" it fails on LoadLanguageFromXml even though it's a valid regex. I thought maybe I had to escape the ? - but xml spy doesn't seem bothered by it.

Can you explain this behavior to me?

Thanks,
Robert Conde

Comments (5)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Keep in mind that our regex engine is custom written so it may not match exactly with other engines, but it should be very close.

This pattern should work for you:
While\s*\( ([^\)]*) \)

With our engine, using the .* as you were will not work correctly. You might also want to increase the value of the LexicalParserLineLookBehind when you make patterns like this.


Actipro Software Support

Posted 15 years ago by rconde01
Avatar
Ok - I'll check that out, though I am rather confused as to why you didn't use the regex library built into the framework
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
I don't really want to get into the technicalities but the .NET regex engine is no good for the type of searching operations we have to perform for our lexical parsing. Although in general use, their engine may be faster, integrating it with what we have to do (if even possible) would be much slower than ours.


Actipro Software Support

Posted 15 years ago by rconde01
Avatar
Ok - your suggestion worked - but going further, the following does not...

^\s*While\s*\(([^\)]*)\)\s*;


The ^\s* at the begginning breaks it. Why?
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
I copied your pattern in there exactly and it worked ok here.


Actipro Software Support

The latest build of this product (v2020.1 build 0400) was released 0 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.