Bookmarks from Expressions

Overview

Bookmarks from Expressions creates bookmarks from regular-expression matches in the document text. Build a list of rules — each one a pattern, the bookmark level its matches land on, and an optional title template — and the command bookmarks every match of every rule, nesting the results into a tree by their levels in page order.

One rule matching Chapter\s+\d+ at level 1 and another matching Section\s+\d+\.\d+ at level 2 produce chapters with their sections nested underneath, exactly as they occur in the document.

The Bookmarks from Expressions dialog
The Bookmarks from Expressions dialog.

How to use

  1. Open the PDF you want to bookmark.
  2. Go to Plug-Ins > Bookmarks > Bookmarks from Expressions (Ctrl+Alt+X).
  3. Type a pattern (or pick one via Regex Library), choose its Level, optionally give it a Title template, and click Add Rule.
  4. Repeat for further heading levels. Select a rule to edit it, then Update; Remove deletes it.
  5. Optionally save the rule set as a named configuration for reuse.
  6. Click OK. A summary reports how many bookmarks were created.

Note

Typing a single pattern and pressing OK without Add Rule still works — the fields run as a one-rule set, like the original version of this command.

Title templates

By default a bookmark's title is the matched text. A template rebuilds it from capture groups, using the same convention as Search and Replace: $1, $2 insert groups, $& the whole match.

PatternTemplateMatchBookmark title
Invoice INV-(\d+)Invoice $1 Invoice INV-0042Invoice 0042
(Chapter \d+): (.+?)\.$2 ($1) Chapter 3: Results.Results (Chapter 3)

How pages are matched

Warning

This engine does not support inline flags such as (?i) or look-behind assertions; the dialog rejects such patterns when you add them. Use a character class such as [Cc]hapter for case-insensitive matching.

See also