$1 etc. do not work in Replace of Find & Replace

Bug #465323 reported by jimav
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenOffice
Invalid
Undecided
Unassigned
libreoffice (Ubuntu)
Fix Released
Undecided
Unassigned
openoffice.org (Ubuntu)
Won't Fix
Undecided
Unassigned

Bug Description

Binary package hint: openoffice.org

In Find & Replace, the use of (...) in the Find expression is supposed to create a reference which can be used in the Replace expression via $1 ($2 for the second (...) etc.). At least that is how I read the OO docs on Regular Expressions. It is also how regular expressions work in many other programs.

However, using $1 in the Replace field just puts in a litera "$1" instead of substituting the text from the "Search for" expression.

EXAMPLE:
If the text contains "My dog has fleas", then setting the Search expression to "My (...) has fleas" and the Replace expression
to "My $1 is smart" Should change the text to "My dog is smart". However, the result is "My $1 is smart".

ProblemType: Bug
Architecture: amd64
Date: Fri Oct 30 11:44:35 2009
DistroRelease: Ubuntu 9.10
Package: openoffice.org-core 1:3.1.1-4ubuntu2 [modified: var/lib/openoffice/basis3.1/program/services.rdb]
ProcEnviron:
 PATH=(custom, no user)
 LANG=en_US.UTF-8
 SHELL=/bin/bash
ProcVersionSignature: Ubuntu 2.6.31-12.41-generic
SourcePackage: openoffice.org
Uname: Linux 2.6.31-12-generic x86_64

Revision history for this message
jimav (james-avera) wrote :
Revision history for this message
WeatherGod (ben-v-root) wrote :

Just to be sure, did you check off "Regular expression" under the More Options pane?

Revision history for this message
jimav (james-avera) wrote : Re: [Bug 465323] Re: $1 etc. do not work in Replace of Find & Replace

Yes, I'm pretty sure Regular Expression was checked.
The example I gave in the bug report is a real example.

Does the example work for you? If so, then there must be some other state setting somewhere which affects this.

The reason I'm sure Regular Expression was checked is that the "(...)" in the search field matched any three characters. If REs were not enabled, it would have only matched literal paren+3dots+paren.

-Jim

----- Original Message ----
From: WeatherGod <email address hidden>
To: <email address hidden>
Sent: Fri, October 30, 2009 4:20:09 PM
Subject: [Bug 465323] Re: $1 etc. do not work in Replace of Find & Replace

Just to be sure, did you check off "Regular expression" under the More
Options pane?

--
$1 etc. do not work in Replace of Find & Replace
https://bugs.launchpad.net/bugs/465323
You received this bug notification because you are a direct subscriber
of the bug.

Status in “openoffice.org” package in Ubuntu: New

Bug description:
Binary package hint: openoffice.org

In Find & Replace, the use of (...) in the Find expression is supposed to create a reference which can be used in the Replace expression via $1 ($2 for the second (...) etc.). At least that is how I read the OO docs on Regular Expressions. It is also how regular expressions work in many other programs.

However, using $1 in the Replace field just puts in a litera "$1" instead of substituting the text from the "Search for" expression.

EXAMPLE:
If the text contains "My dog has fleas", then setting the Search expression to "My (...) has fleas" and the Replace expression
to "My $1 is smart" Should change the text to "My dog is smart". However, the result is "My $1 is smart".

ProblemType: Bug
Architecture: amd64
Date: Fri Oct 30 11:44:35 2009
DistroRelease: Ubuntu 9.10
Package: openoffice.org-core 1:3.1.1-4ubuntu2 [modified: var/lib/openoffice/basis3.1/program/services.rdb]
ProcEnviron:
PATH=(custom, no user)
LANG=en_US.UTF-8
SHELL=/bin/bash
ProcVersionSignature: Ubuntu 2.6.31-12.41-generic
SourcePackage: openoffice.org
Uname: Linux 2.6.31-12-generic x86_64

Revision history for this message
Chris Cheney (ccheney) wrote :

It works fine for me with OOo 1:3.1.1-5ubuntu1 in Ubuntu 9.10

Changed in openoffice.org (Ubuntu):
status: New → Incomplete
Revision history for this message
Chris Cheney (ccheney) wrote :

It seems that I had to hit 'Replace' twice for my test since the first time it highlighted it and the second actually replaced it. Did it work for you when you tried that?

Revision history for this message
WeatherGod (ben-v-root) wrote :

The example also does work in OOo 3.0 in Ubuntu 9.04. I would double-check the example and let us know if the problem still exists.

Revision history for this message
jimav (james-avera) wrote :

Hmm, since others can not repo this, I suspect I'm doing something slightly different than they are (or perhaps I'm completely mis-understanding how Find & Replace are supposed to work).

So here is an extremely explicit test procedure. I will attach screen shots showing the OO windows before and after.

Chris & WeatherGod, would you please try this exact scenario?

PROCEDURE:
   1. Start oocalc from the command line with an existing .ods document
   2. Tools->Macros->OrganizeMacros->oenoffice.org Basic...
   3. In the "Macro from" pane, specify some module you can edit (under My Macros, for example)
   4. Click Edit

   5. Paste in the following code:
Sub Foo
  Dim i as Integer
  MsgBoxx("Blah")
  MsgBoxx("Blah")
  MsgBoxx("Blah")
  i = 123
End Sub

  6. Select (highlight with left-mouse-button) several lines including the lines containing MsgBoxx
  7. Control-F (opens Find & Replace dialog)
  8 Set "Search for" field to "(......)x" without quotes
     Set "Replace with" to "$1" without quotes
     [Click 'More Options' if necessary to open drop-down]
     Check 'Regular expressions'
     Check "Current selection only"
     (only those 2 check-boxes checked)
  9. Click Replace

What should happen is "MsgBoxx" is changed to "MsgBox". What actually happens on my system is they are changed to "$1x"

Please see attached screen shots and compare with what you see.
Thanks.

Revision history for this message
jimav (james-avera) wrote :
Revision history for this message
WeatherGod (ben-v-root) wrote :

Ok, I can confirm that this bug happens when editing a Macro. What is odd is that if I place the same text in Writer and do a Find/Replace, it works as expected.

Changed in openoffice.org (Ubuntu):
status: Incomplete → Confirmed
Revision history for this message
WeatherGod (ben-v-root) wrote :

I should also note that I also tested against OOo 3.1 in Fedora 11, so I believe that this bug needs to be addressed upstream.

Chris Cheney (ccheney)
tags: added: karmic
Changed in openoffice.org (Ubuntu):
status: Confirmed → Won't Fix
Revision history for this message
penalvch (penalvch) wrote :

jimav, does this issue occur for you in LibreOffice? If your using Lucid or Maverick feel free to type at the Terminal:

sudo add-apt-repository ppa:libreoffice/ppa && sudo apt-get update && sudo apt-get -y upgrade && sudo apt-get -y install libreoffice-writer

Changed in libreoffice (Ubuntu):
status: New → Incomplete
Changed in openoffice:
status: New → Invalid
Revision history for this message
Björn Michaelsen (bjoern-michaelsen) wrote : migrating packaging from OpenOffice.org to Libreoffice

[This is an automated message.]
There are no new official OpenOffice.org releases in Ubuntu packaging anymore => Won't Fix

If the problem persists, please mark this bug as "also affects project Libreoffice" or "also affects distribution Libreoffice (Ubuntu)" if that has not happened already.

Please leave references to upstream OpenOffice.org bugs in place to allow cross pollination.

Revision history for this message
jimav (james-avera) wrote :

It seems to have been fixed in Libre 3.4.3 (tested writer & calc).

Changed in libreoffice (Ubuntu):
status: Incomplete → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.