indiWiz.com

Subhash's Tech Log

JEdit, powerful search and replace using BeanShell

with one comment

JEdit is my favorite text editor. And today I was pleased to find some powerful scripting capability in its search and replace functionality. Basically I wanted to enclose a RegularExpression pattern with:

<a href="">PATTERN</a>

The Search and Replace dialog provided an option Return value of a BeanShell snippet. So whatever RegularExpression pattern grouping I provided, I was able to access them using the BeanShell variable _1 to _9. So my final replace statement became:

"<a href\"\">" + _1 + "</a>"

Cool solution to a simple problem.

jedit_search_replace

Written by Subhash Chandran

December 17th, 2008 at 2:27 pm

Posted in OpenSource,Scripting

Tagged with

One Response to 'JEdit, powerful search and replace using BeanShell'

Subscribe to comments with RSS or TrackBack to 'JEdit, powerful search and replace using BeanShell'.

  1. $1 is simpler. You don’t have to use escape characters.

    Ino

    8 Jan 10 at 11:02 am

Leave a Reply