indiWiz.com

Subhash's Tech Log

JEdit, powerful search and replace using BeanShell

with 2 comments

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

2 Responses 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

  2. I think $1 doesn’t work when “Return value from beanshell” is checked, _1 is the only way.

    matt

    19 Jan 11 at 9:24 pm

Leave a Reply