Copy link to clipboard
Copied
Hi Scripter,
we want to check all the text content within a book with a regular expression and JavaScript.
We have no idea how it works.
Can someone help us?
Thank you.
Copy link to clipboard
Copied
Hi andrée91081766,
you can do this without ExtendScript.
Open Search-window (ctrl-f),
select "text
type in your regular expression
select "regular expression"
select "Book". (search in)
That's it.
[EDIT] You need at least FM 12 for regexp
Copy link to clipboard
Copied
Hi Klaus,
anhand des Namens glaube ich, Du versteht Deutsch
Das macht mir die Erklärung einfacher.
Wir möchten per Script auf mehrere Bücher sehr viele RegEx anwenden.
Die Logik um den Text zu druchsuchen und in einer Schleife die RegEx anzuwenden ist nicht das Problem.
Mein Problem liegt beim Auslesen des kompletten Textes im Buch.
Vielen Dank schonmal für Deine Antwort.
VG
André
Copy link to clipboard
Copied
Hi André,
my answer is in English, because not all of the other supporter here in the forum speek German.
I just summarize your answer in English:
You try to read the found text.
- You can replace the found text with search/replace, also
Or what do you want to do with that text?
When you say complete text, do you mean the whole text of the paragraph or what exactly do you mean with "complete text"
Could you plese describe a little more in detail, what you are trying to achieve?
Copy link to clipboard
Copied
I´m sorry.
i have many Books with many pages. All these Books i want to check completly with many regular expressions. Future Books too.
I want to write a script witch check all Books for mistakes.
For all Mistakes i have 30-40 regular expresions and i only want to start one script for all.
How to iterate with a JavaScript through the books to get the text in the frames and manipulate it.
I hope you understand my bad english ^^
Copy link to clipboard
Copied
Hi André,
with the function "find" you only can only access a document, but not a book.
So your way will be:
- open the Book
- find all textinsets -> array
- open all textinsets one by one.
- use "find" for every single FM-file in a loop for every regexp.
Sounds easy, but the devil is in the details.
Copy link to clipboard
Copied
Hi André,
Here is an alternative approach. Regarding the amount of documents and the amount of RegEx' all this stuff could get a very time consuming process within FrameMaker. And perhaps, depending on your background, this is easier than handling text within FrameMaker.
My idea:
1. Use an ExtendScript to open all documents in a directory and save each to MIF
2. Write an exe in any language of your choice. This executable is responsible for your search and replace part in the MIF file directly *)
3. Call this executable with ES function File.execute()
4. If exe has finished open MIF files again and save them back to FM
5. delete MIF files, as they are not needed any more
(Recommendation: save MIFs in the same document directory, to avoid issues with file references)
*) If you like XML, have a look at Scott Prentice' MIF2ML converter Leximation: MIFML .If you have done the MIF-Export part, you are now able to convert these to MIFML and back again.
Between these two steps you can add SAXON as XSLT processor and do all that RegEx stuff with XSLT2.0. You are able to address Strings with XPath directly. You do not need to parse MIF by your own and you don't need to program high end stuff.
I think the XML path would be the way I would go. It's worth to give it a try.
BTW: my English is not better, so go ahead.
Markus
Copy link to clipboard
Copied
FYI: there's also a German FrameMaker User Group