[Resolved] Re: Regex Find & Replace
NoOp
glgxg at sbcglobal.net
Thu Mar 11 01:30:20 UTC 2010
On 03/10/2010 05:24 PM, Knute Johnson wrote:
> On 3/10/2010 4:07 PM, NoOp wrote:
>> Tried this on the OpenOffice.org users list, but no response yet. So,
>> I'm hoping someone here is familiar with Regular Expression& can help:
>>
>>
>>> Sorting through a flat data file (GEDCOM genealogy database file) in
>>> Writer (3.2 - linux) and I am attempting to find and replace the following:
>>>
>>> lowercase m preceded by a space and followed by uppercase A-Z.
>>>
>>> Example:
>>> (space)mAnderson
>>> replace as
>>> (space)Anderson
>>>
>>> I found that I can easily _find_ using:
>>> m[A-Z]
>>> but can't figure out how to replace the 'm' with a space and leave the
>>> following A-Z letter in place.
>>>
>>> Any suggestions on how I accomplish this?
>>
>>
>
> s/m([A-Z])/$1/
>
Yep & thanks! Got the following response on the OOo list:
> Yes: just enclose the part you want to keep in parentheses; you can
> then refer to that in the "Replace with" field. Search for:
> m([A-Z])
> and replace with:
> $1
> - where both those strings have a leading space, of course. The "$1"
> in the "Replace with" field refers to the first (here the only)
> parenthesised reference in the "Search for" string. So the replace
> string is a space followed by whatever capital letter was matched by
> your [A-Z].
>
> You will need to have both "Match case" and "Regular expressions"
> ticked, of course - but you knew that.
>
> I trust this helps.
>
> Brian Barker
More information about the ubuntu-users
mailing list