RegexSR - Quick Start
RegexSR is a very easy-to-use and powerful tool (written in Java) to create and test complex regular expressions. The plugin system provides extra functionalities, such as transforming expressions into Java code, and allows the user to create his own extensions.
Features include testing regular expressions, handling text through regular expressions or plugins, renaming files, developing plugins, and managing expressions in the repository.
An excellent website to learn regular expressions can be found at http://www.regular-expression.info/ or, in French (for Java developers), at http://cyberzoide.developpez.com/java/regex/
Tips for the Text and Filenames tabs
- Back references look like
\n
in the search field and like $n
and in the replace field, where n
is the n
th reference. See the examples below.
- If you want to record temporary (for this session) an expression, press the
return
key while editing in the Search
field or the Replace by
field. Use then the up and down arrow keys to access formerly recorded expressions.
- If you want to record an expression permanently, use the repository.
Tips for the Text tab only
- Pressing the
Replace
button or the Replace All
button, as well as launching a plugin, will first save the current text; pressing the Undo
button will restore the saved text.
- Deselect
Live evaluation
when you treat big files. Pressing return
in the Search
field will start the search.
- Searches and replacements are made on the selected text, if any, or on the whole text if there is no selection.
Tips for the Filenames tab only
- You can also open a directory with a drag-and-drop operation over the text zone.
Testing
Use the following expressions to test the program:
Search = [\w%-]+(\.[\w%-]+)*@[\w%-]+(\.[\w%-]+)*\.[\w%-]{2,4}
should match only correct e-mail addresses.
Search = \b(\w+)\b \b\1\b
and Replace by = $1
should remove all doubled words in a String, like in "I like very very much regular expressions".
More examples can be found at http://www.regular-expression.info/examples.html
Repository
The repository writes its content in XML files, /system/repositoryText.xml
and /system/repositoryFilenames.xml
. These files can be directly edited in any text editor, for instance to make backups or to import expressions from someone else.
Plugins
If you have knowledge about Java programming, writing you own plugin for RegexSR is a very easy task. Let us start with an example that we call MyFirstPlugin
. Create a class called MyFirstPlugin.java
that extends PluginText
and that redefines its execute
method. The file has to be saved in the /plugins/text/myfirstplugin
directory.
package plugins.text.myfirstplugin;
import kernel.*;
import javax.swing.*;
public class MyFirstPlugin extends PluginText {
public MyFirstPlugin() {
setSummary("The summary");
setDescription("The description.");
}
public void execute() {
JOptionPane.showMessageDialog(this, "My First Plugin!", "About...",
JOptionPane.INFORMATION_MESSAGE);
}
}
Define your classpath during compilation in order to access the PluginText
and Tools
classes: javac -cp .;../../../dev MyFirstPlugin.java
That's it! RegexSR will automatically find your plugin during runtime and allow you to test it.
Documentation about the PluginText
and Tools
classes is available in the /dev/javadoc
directory. It is also recommended to study the following plugins (in the given order): HelloWorld
, Paragraph
, Sort
, Accents
, and HelloWorldInt
.
Contact
Bug reports, suggestions, and plugins you have developped are welcomed at regexsr@fastmail.fm. Thank you very much in advance for your contribution!