Copy link to clipboard
Copied
Good day. I am trying to make an Index list - surname/name/page. However I cannot add one single name with "add all" function.
In my Lithuanian language, there is a grammatical case system.
NAME SURNAME :
Jonas Jonaitis
Jono Jonaičio
Jonui Jonaičiui
I would need to highlight every name grammatical case and add it to the index, but the name is the same, only the case is not. And I would have several entries of the same name under "X" letter.
In this example, I would need the grep to find all grammatical cases of Jon* Jonai* (name/surname) and make it the default name case - Jonas Jonaitis. Then also swap to surname/name style.
The final result should look like:
J
Jonaitis Jonas
I don't know how to write this 😞
Do you think this is too much? Should I just highlight every name with different case, and then just edit generated index? I would just need to figure out how to swap name/surname to surname/name.
Thank you, V.
If searching for all instances of words that start with Jon or Jonai is certain only to return names and nothing else, you can look for
Jon\l+ Jonai\l+
(\l stands for lower-case letter, + means one or more.)
If that's too wide you can specify the case endings:
Jon(as|o|ui) Jonai(tis|čio|čiui)
To mark up Jonas in your document, you can use this script:
var index = app.documents[0].indexes[0];
if (!index.isValid) {
index = app.documents[0].indexes.add();
}
app.findGrepPreferences =
...
Copy link to clipboard
Copied
If you're only looking to swap the first and last name it's pretty simple
Given names are start of sentences
Find
^(.+?) (.+)
Change to
$2 $1
If it's more complicated than that let us know.
Copy link to clipboard
Copied
Another way I've done it before GREP days
Find the space
replace it with a tab
Select the text and convert it to a table
Then swap the columns
Then convert the table back to text
You don't technically need to change the space toa. tab - you can just ty convert to a table and use the space character to invoke the columns and rows etc
Copy link to clipboard
Copied
If searching for all instances of words that start with Jon or Jonai is certain only to return names and nothing else, you can look for
Jon\l+ Jonai\l+
(\l stands for lower-case letter, + means one or more.)
If that's too wide you can specify the case endings:
Jon(as|o|ui) Jonai(tis|čio|čiui)
To mark up Jonas in your document, you can use this script:
var index = app.documents[0].indexes[0];
if (!index.isValid) {
index = app.documents[0].indexes.add();
}
app.findGrepPreferences = null;
app.findGrepPreferences.findWhat = 'Jon\\l+ Jonai\\l+';
found = app.documents[0].findGrep();
if (found.length > 0) {
topic = index.topics.add ('Jonaitis, Jonas');
for (i = found.length-1; i >= 0; i--) {
topic.pageReferences.add (found[i].insertionPoints[0]);
}
}
(Edit: Eugene posted while I was typing away)
Copy link to clipboard
Copied
That makes a lot more sense
Copy link to clipboard
Copied
Thank you very much, this is exactly what I was looking for!
Have a lovely day,
V.