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 269275

Summary: Regular expression searches not predictable when search spans a line
Product: editor Reporter: brettryan <brettryan>
Component: SearchAssignee: Milutin Kristofic <mkristofic>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: Dev   
Hardware: PC   
OS: Mac OS X   
Issue Type: DEFECT Exception Reporter:

Description brettryan 2016-12-09 00:08:05 UTC
Given the following text where the whitespace between words is a single tab character.

one	two	three
four	five	six
seven	eight	nine

Let's imagine we want to replace this with:

   update some_table set val1 = '#col3' where key1 = '#col1' and key2 = '#col3'

where the '#colN' refers to the column in the above text.

A valid expression would be:

    ^([^\t]*)\t([^\t]*)\t([^\t]*)$

However, when this is used the replaced text becomes:

update code_mstr set code_cmmt = 'three' where code_fldname = 'one' and code_value = 'two';update code_mstr set code_cmmt = 'six' where code_fldname = '
four' and code_value = 'five';update code_mstr set code_cmmt = 'nine
' where code_fldname = '
seven' and code_value = 'eight';

Which is because the replacement is being greedy and spanning several lines.

If we change the search pattern to be:

    ^(.*)\t(.*)\t(.*)$

The replacement becomes:

update code_mstr set code_cmmt = 'three' where code_fldname = 'one' and code_value = 'two';
update code_mstr set code_cmmt = 'six' where code_fldname = 'four' and code_value = 'five';
update code_mstr set code_cmmt = 'nine' where code_fldname = 'seven' and code_value = 'eight';

Which is correct, however; these two expressions have different greedy treatment which is confusing and seemingly unpredictable.


Version:

I'm unable to get the latest dev build as it seems the download links on bits.netbeans.org are not available.


Product Version: NetBeans IDE Dev (Build 201610110002)
Updates: Updates available
Java: 1.8.0_111; Java HotSpot(TM) 64-Bit Server VM 25.111-b14
Runtime: Java(TM) SE Runtime Environment 1.8.0_111-b14
System: Mac OS X version 10.12.1 running on x86_64; UTF-8; en_AU (nb)
User directory: /Users/bryan/Library/Application Support/NetBeans/dev
Cache directory: /Users/bryan/Library/Caches/NetBeans/dev