Download NetBeans!

20070411 Wednesday April 11, 2007

Module of the Century: Sandip's Regular Expression Highlighter

It's not often that I post more than one blog entry in a day, so this means that what I have to share is pretty significant. I'm no hero when it comes to regular expressions, so I installed the NBM file from http://www.nbextras.org and then installed Sandip's Regular Expression Highlighter from the newly installed nbextras update center. I needed to construct a regular expression that would capture a "class" attribute in an xwork.xml file, together with its value. After that, even more challenging, I needed to construct a regular expression that would capture everything from an opening <action> tag to a closing </action> tag. So, I started typing in the text field that you see in the toolbar in the screenshot below. As I typed regular expressions, everything in the document that was captured by the expression was highlighted, while I was typing. Not soon after, through trial and error, I had my expression:

Result: class="[a-z."]*

Similarly, I constructed a regular expression for capturing my <action> tags, across multiple lines:

Result: <action [a-z0-9A-Z=" .>]*|<r[a-z=" .></]*|</action>

I realize the results do not cover all possibilities, nor are they perfectly formulated. But clearly they're a good start. Thanks Sandip! Very useful. It really is ideal for learning how regular expressions work. I hope it will be part of 6.0.

Apr 11 2007, 10:37:32 AM PDT Permalink

Trackback URL: http://blogs.sun.com/geertjan/entry/module_of_the_centure_sandip
Comments:

That's something I needed.
Pretty neat :)
Will try it immediately.

Posted by Bipin on April 11, 2007 at 11:30 AM PDT #

The version of RegExpHighlighter on nbextras is older. You may want ot get the latest version of the module from my update center described here: http://blogs.sun.com/scblog/entry/netbeans_module_update_center

Posted by Sandip on April 11, 2007 at 04:18 PM PDT #

Thanks Sandip.
I have installed the older one; will use newer version soon.
By the way, I hope Geertjan doesn't mind us converting his blog into a chat template [And if he doesn't mind than may be he should collaborate the developer's collaboration module into his blog] ;)

if(Geertjan.status==frowning()){
bipin.status=ducking();
}

Posted by Bipin on April 11, 2007 at 05:33 PM PDT #

Bipin, no problem if you want to chat to Sandip or others via this blog! :-) Sandip, what's the difference between the version in your blog and the version in nbextras (and when will you update the one on nbextras)?

Posted by Geertjan on April 12, 2007 at 01:25 AM PDT #

Basically bug fixes.

The updates to nbextras are slow as the work is done manually by volunteers. That is why I have continued to have my own update center. That way I have full control.

Now NetBeans.org has plugin portal which allows uploding/updating...I will be switching to that some time in future.

Posted by Sandip on April 12, 2007 at 09:59 AM PDT #

Very nice, that's one of the features from jEdit I was still missing in NetBeans.

Posted by Marco Slot on April 13, 2007 at 01:36 PM PDT #

RegExpHighlighter is also on NB.org plugin portal now:

http://plugins.netbeans.org/PluginPortal/

Posted by Sandip on April 13, 2007 at 05:45 PM PDT #

great it ll be helpful :D

Posted by nbuser on April 17, 2007 at 11:27 AM PDT #

I understand that kind of excitement with higjlighting, but I would like to ask you how much of regular expressions you have actually written in Java applications. I think that this feature of the language is of very limited and specific area of usage - text processing / parsing.

Posted by David Rozenberg on April 19, 2007 at 03:53 PM PDT #

It seems to have a dependency that prevents it from working with my 6.0 daily build: " Plugin Regular Expression Highlighter cannot match its dependencies: module org.netbeans.modules.editor.lib/1 = 1 " Is there something else I must install?

Posted by Stephen on April 26, 2007 at 06:55 AM PDT #

The version 1.6 which has a fix for the editor.lib/1 dependency issue, is on the plugin portal:

http://plugins.netbeans.org/PluginPortal/

Please get it from there.

Posted by Sandip on April 26, 2007 at 09:20 AM PDT #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed