Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#411 SearchAndReplace.escapeRegexp() wrong

closed-invalid
5
2012-06-08
2012-03-29
Thiemo Kellner
No

SearchAndReplace.escapeRegexp() uses a wrong or outdated escape character string.
For instance following code in a macro leads to the error/exception at the bottom of the description.
String excludePathRegexpCaseInsensitive = SearchAndReplace.escapeRegexp(
"\d",
true);

Line 984 of jedit4.5.1source\jEdit\org\gjt\sp\jedit\search\SearchAndReplace.java reads
"\r\t\\()[]{}$^*+?|."

I suppose it should read
"\B\b\d\D\s\S\t\w\W\x\\()[]{}$^*+?|."

jEdit 4.5.1
java.version=1.6.0_26
java.vm.version=20.1-b02
java.vm.name=Java HotSpot(TM) Client VM

Sourced file: C:\Documents and Settings\thiemo\.jedit\macros\getSearchResultWithoutUnwantedPaths.bsh Token Parsing Error: Lexical error at line 32, column 6. Encountered: "d" (100), after : "\"\\": <at unknown location>

at org.gjt.sp.jedit.bsh.Interpreter.eval(Interpreter.java:698)
at org.gjt.sp.jedit.BeanShell._runScript(BeanShell.java:331)
at org.gjt.sp.jedit.BeanShell._runScript(BeanShell.java:279)
at org.gjt.sp.jedit.BeanShell.runScript(BeanShell.java:205)
at org.gjt.sp.jedit.Macros$BeanShellHandler.runMacro(Macros.java:1040)
at org.gjt.sp.jedit.Macros$Macro.invoke(Macros.java:462)
at org.gjt.sp.jedit.gui.InputHandler.invokeAction(InputHandler.java:342)
at org.gjt.sp.jedit.jEdit$4.invokeAction(jEdit.java:3249)
at org.gjt.sp.jedit.jEdit$4.invokeAction(jEdit.java:3231)
at org.gjt.sp.jedit.EditAction$Wrapper.actionPerformed(EditAction.java:212)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Discussion

    • assigned_to: nobody --> jarekczek
    • status: open --> closed-invalid
     
  • Thiemo, please submit a bug report first. I tried to reproduce the error you reported, but notice that "\d" is incorrect as a java string. I cannot run even:
    print("\d")
    from BeanShell console, getting the same exception.

     
  • Alan Ezust
    Alan Ezust
    2012-06-08

    you need to double-escape the \ when you are in a quoted java string, for things like \d. it should read .
    print ("\\d")