This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 160807

Summary: IllegalArgumentException: Illegal group reference
Product: editor Reporter: sgtgarcia <sgtgarcia>
Component: SearchAssignee: issues@editor <issues>
Status: RESOLVED DUPLICATE    
Severity: blocker CC: jkovalsky, scottpron
Priority: P3 Keywords: NETFIX, SIMPLEFIX
Version: 6.x   
Hardware: All   
OS: All   
URL: http://statistics.netbeans.org/exceptions/detail.do?id=10891
Issue Type: DEFECT Exception Reporter: 10891
Attachments: stacktrace

Description sgtgarcia 2009-03-21 22:18:58 UTC
Build: NetBeans IDE Dev (Build 200902231810)
VM: Java HotSpot(TM) Client VM, 11.0-b15, Java(TM) SE Runtime Environment, 1.6.0_10-b33
OS: Linux, 2.6.27-13-generic, i386

User Comments:
rptmaestro: This error occured while I was performing a search and replace in a sql file

GUEST: Doing a "find and replace" using regular expressions. I wasn't sure how to put newline characters ("\n") in the "Replace With:" box. I tried \n, which just rendered "n", then i tried $n, which resulted in this error.

sgtgarcia: Search and replace in file whith regular expression in search

GUEST: Search and replace using regexp

mschovanek: to reproduce:
-----------
1) in a editor window invoke Find & Replace
2) check Regular Expressions box
3) find: a replace: ${a}
ERROR: IDE throws the IAE

We should improve the way how IDE handles this RE errors. Eg. in FCS build user can easily miss it.

GUEST: Doing a search and replace with $$ in the replacement text

petiex: find replace with regular expressions



Stacktrace: 
java.lang.IllegalArgumentException: Illegal group reference
        at java.util.regex.Matcher.appendReplacement(Matcher.java:713)
        at java.util.regex.Matcher.replaceFirst(Matcher.java:861)
        at org.netbeans.modules.editor.lib2.search.DocumentFinder.findReplaceImpl(DocumentFinder.java:253)
        at org.netbeans.modules.editor.lib2.search.DocumentFinder.findReplaceResult(DocumentFinder.java:312)
        at org.netbeans.modules.editor.lib2.search.EditorFindSupport.findReplaceInBlock(EditorFindSupport.java:596)
        at org.netbeans.modules.editor.lib2.search.EditorFindSupport.replaceAll(EditorFindSupport.java:779)
Comment 1 sgtgarcia 2009-03-21 22:19:06 UTC
Created attachment 78586 [details]
stacktrace
Comment 2 Vitezslav Stejskal 2009-03-23 17:21:58 UTC
Ideally the dialog should verify entered regex patterns and clearly communicate errors to the user without crashing.
Comment 3 Jiri Kovalsky 2009-03-30 14:22:00 UTC
Vita Stejskal agreed that he would review and integrate a patch for this issue contributed by the NetFIX [1] team.

[1] http://wiki.netbeans.org/NetFIX
Comment 4 Alexei Mokeev 2009-04-16 10:34:51 UTC
Pure duplicate of 119819

*** This issue has been marked as a duplicate of 119819 ***