| View previous topic :: View next topic |
| Author |
Message |
onmotry Newbie

Joined: 08 Jun 2012 Posts: 1
|
Posted: Fri Jun 08, 2012 8:06 am Post subject: Find/replace a field variable? |
|
|
Hello,
I have a long text (150K words) and I'd like to be able to number the occurrences of a certain word (say lambda). I would like for the nth lambda in the text to show up as "n lambda"
So basically, I want to insert an incrementing number field in front of every lambda in the text. I can't figure out how to put the field in the replace box, however. I was wondering if there's a way to do this.
Thank you! |
|
| Back to top |
|
 |
Robert Tucker Moderator


Joined: 16 Aug 2004 Posts: 3367 Location: Manchester UK
|
Posted: Fri Jun 08, 2012 8:36 am Post subject: |
|
|
I suspect you will need a macro or a field connected to a database. _________________ LibreOffice 3.6.6 on Fedora 18, LibreOffice 4.0.2 on Ubuntu 13.04 (Double Boot) |
|
| Back to top |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8984 Location: Lexinton, Kentucky, USA
|
Posted: Sat Jun 09, 2012 8:00 am Post subject: |
|
|
Here's a macro that numbers the word "the" as "(n) the".
| Code: | Sub InsertNumber
oDoc = ThisComponent
n = 1
FandR = oDoc.createReplaceDescriptor
FandR.SearchString = " the "
Find = oDoc.FindFirst(FandR)
While Not isNull(Find)
Find.String = " (" & n & ")" & Find.String
n = n + 1
Find = oDoc.FindNext(Find.End,FandR)
Wend
End Sub |
|
|
| Back to top |
|
 |
|