Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 396224 - Regex replace all doesn't handle capture groups
Summary: Regex replace all doesn't handle capture groups
Status: RESOLVED FIXED
Alias: None
Product: Orion
Classification: ECD
Component: Client (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 2.0 M2   Edit
Assignee: John Arthorne CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-10 16:16 EST by John Arthorne CLA
Modified: 2012-12-14 10:46 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Arthorne CLA 2012-12-10 16:16:06 EST
Start with HTML like this:

  <tr id="orion-node-prototype">
  <tr id="search-type">
  <tr id="editor-regex">

Do Ctrl+F, and search for this regex: <tr (id=".*")>
Select the regex option, and replace with: <h3 $1>

Hit replace, and this works correctly. It converts table rows to headers. Now instead try Replace All. The capture group does not get substituted and you end up with:

<h3 $1>
<h3 $1>
<h3 $1>
Comment 1 Adrian Aichner CLA 2012-12-11 08:10:26 EST
Thanks for your testing, John.

I have a fix, tested in a local selfhosting setup and commited to my github fork.

I cannot do another pull request on github at the moment.

It looks like my commit got added to https://github.com/eclipse/orion.client/pull/20 which is still shown as open?

Please advise in case I need to do aything to get this merged.

Thanks!
Adrian
Comment 2 Adrian Aichner CLA 2012-12-11 18:09:13 EST
This is my commit fixing this bug:

https://github.com/anaran/orion.client/commit/e2cbc71a5624ee6a80de303fa038ac34a0a0b7c1

Adrian
Comment 3 Adrian Aichner CLA 2012-12-12 12:30:31 EST
I have rebased, merge a minor conflict, and pushed my merge to my github repo.

From my review of the original pull request as it looks today
https://github.com/eclipse/orion.client/pull/20
should be pullable now.

Best
Adrian
Comment 4 John Arthorne CLA 2012-12-14 10:46:48 EST
Thanks for this fix Adrian. I have pushed it to master:

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=49230c53f7b4b1afc0cc73fd555d836107afe304

While doing testing I found some cases that didn't work right that I also fixed (I believe these bugs existed before your patch):
 - If the search term was empty, it was still replacing the first occurrence of empty string with the replace text (it should do nothing)
 - If there was no match for the search term and you clicked Replace, it would replace the current selection (it should do nothing)

I have fixed these additional problems and pushed everything to master.