Twistpad Carthago Software forums / Twistpad /  

 Regluar expression annoyances

 
Dirhael
Member
#1 | Posted: 16 Apr 2007 12:01 
Hello, new member here. Just registered Twistpad today, and for the most part I really like it but there is one bug/annoyance that I'd love to see removed :)
I frequently use regular expression to format my files, but there seems to be a problem using iterators. To better explain, consider the following expression:

\#[a-fA-F0-9]{3,6}

Now in a CSS file this would (or should) have selected all the HEX colors from 3-6 chars in length. The problem is, Twistpad will only select the first 3 characters no matter what you do. You could try changing the {3,6} part to {3,} but you would get the same result. It would seem that the it treats it as you should have written {3}.

Another problem I just encountered while trying to work around this problem is that if you write something like F*?;, it will return any and all occurences of the ";" char even when there's no "F" in front of it. The expected result of that expression is that it should only return the "FF;" part of a string like "#FF00FF;" , and not the ";" part of a string like "#000000;"

Finally, querys like F* does not return anything at all even it your file contains strings like the ones mentioned above.

Hopefully you can fix this in the next release, because surely this behavior can not be intended? :)

Andre Santos
Carthago
Moderator
#2 | Posted: 16 Apr 2007 14:31 
Hi,

Thanks for registering Twistpad.

For the first RE issue you mention,you should enable the greedy flag.
So something like : (?G)\#[a-fA-F0-9]{3,6} works as you described.

The second one you should use a dot before the asterisk: F.*?;
It should now recognize all strings between F and ;

Please expect improvements in the regular expression engine used by Twistpad in future versions. (global modifiers like the greedy flag, sub-expression replaces and more)

Thanks,

André Santos
Carthago Software Support
http://www.carthagosoft.net

Dirhael
Member
#3 | Posted: 16 Apr 2007 15:09 | Edited by: Dirhael 
Ah, didn't know that. I had read the information in the help file, but it didn't actually mention that I had to set that flag. I just tested your syntax and it does exactly what I expected, except for the second case where I had to add (?-i) to get it working as expected (case-sensitive...although I could just have ticked the box). Thanks for helping me out, it's much appreciated :)

You mention improvements in the future, and in that case I'm wondering if there's a chance of having it work much the same way as PHP's preg RegEx (perl-compatible)? If so, it would be great as I find that implementation one of the easiest to work with and it's very close to what you already have in Twistpad. In any case, I will be able to adjust no matter what you decide upon as I'm already happy with your product as is, now that I know what I was doing wrong ;) Perhaps updating the help file might be a good idea tho'?

Oh and before I forget: This doesn't actually have anything to with this topic, but I was wondering if you had considered releasing a plugin SDK? It would be great being able to create our own extension for the editor :)

Andre Santos
Carthago
Moderator
#4 | Posted: 17 Apr 2007 14:33 
Hi,

Glad it helped you sorting out those RE issues.

Dirhael wrote:
You mention improvements in the future, and in that case I'm wondering if there's a chance of having it work much the same way as PHP's preg RegEx (perl-compatible)? If so, it would be great as I find that implementation one of the easiest to work with and it's very close to what you already have in Twistpad. In any case, I will be able to adjust no matter what you decide upon as I'm already happy with your product as is, now that I know what I was doing wrong ;)


It's a possibility, but Twistpad Regular Expression Engine is already close to the Perl RE Standard. Anyway I'll see what the options are to improve the RE Engine.


Perhaps updating the help file might be a good idea tho'?


Yes, I expect to update the Help file, particularly the RE section.

Hopefully an updated Help file will be bundled with the upcoming Service Release 1 of Twistpad 1.58

Sometimes a lot of time is put into the product documentation, and it's my experience that most people don't read it anyway. ;-)

Dirhael wrote:
Oh and before I forget: This doesn't actually have anything to with this topic, but I was wondering if you had considered releasing a plugin SDK? It would be great being able to create our own extension for the editor :)


Yes, a pascal (Delphi) Sample with full source should be uploaded soon (with the respective API documentation)

Thanks,

André Santos
Carthago Software Support
http://www.carthagosoft.net

Dirhael
Member
#5 | Posted: 19 Apr 2007 07:32 
Looking forward to taking a look at the SDK :)

Twistpad Carthago Software forums / Twistpad /
 Regluar expression annoyances

Your Reply Click this icon to move up to the quoted message


 
Only registered users are allowed to post here. Please, enter your username/password details upon posting a message, or register first.

 

  Powered By minibb