Skip to main content
Known Participant
April 5, 2019
Answered

Regex capture when searching for a character or paragraph tag?

  • April 5, 2019
  • 2 replies
  • 713 views

Is there a way in the Find/Change dialog to search for a character tag, capture the corresponding text and use that text in the Change field?

    This topic has been closed for replies.
    Correct answer Lynne A. Price

    Ah, I think I misunderstood your original question.

    If I've got it right this time, you want to add a prefix and suffix to all text strings tagged with a particular character tag? That explains why you referred to regular expressions in the title of this thread. FrameMaker can use regular expression conventions to add a prefix and suffix to a found string, but only if that string was found by searching for a regular expression. A variation of the complex instructions in my previous suggestion would let you search for the character tag, then search for a regular expression consisting of the string you've already found, and then use regular expression conventions to add the prefix or suffix. Not something that would be very practical to repeat numerous times.

    This may be a good candidate for scripting.

        --Lynne

    2 replies

    Barb Binder
    Community Expert
    April 7, 2019

    Hi Pdeitel:

    I can do this in InDesign, because InDesign separates formatting from the Regex queries. I can't see any way to accomplish this in FrameMaker. I wish we could get more of InDesign's Find/Change capabilities into FrameMaker.

    ~Barb

    ~Barb at Rocky Mountain Training
    Inspiring
    April 5, 2019

    When you have selected text in your document and you switch from the document window to the Find/Change dialog box when the current search option requires text, FrameMaker copies the selected text into the search field.

    In your case, you can therefore:

    1. Select Character Tag from the pull-down menu at the top of the Find/Change dialog box, type the name of the character tag you want in the text box underneath that option, and click Find or press Enter.

    2. The focus is still in the dialog box and you want to switch back to the document without removing the selection. You can do so either with Shift F7 or by clicking an empty spot on the title bar at the top of the document window.

    3. Go back to the dialog box with Ctrl-f or Edit > Find/Change. FrameMaker copies the selected text (the result of the first search) into the search field in the dialog box but the search type is still set to Character Tag.

    4. Change it to Text and click Find or press Enter.

         --Lynne

    pdeitelAuthor
    Known Participant
    April 6, 2019

    Hi Lynne, Maybe I am misunderstanding your response, but I am not trying to look for specific text.

    I am looking for arbitrary text of in a given character format so that I can then wrap that text in additional characters.

    I need to capture that arbitrary text so I can use it in the change box.

    Lynne A. PriceCorrect answer
    Inspiring
    April 6, 2019

    Ah, I think I misunderstood your original question.

    If I've got it right this time, you want to add a prefix and suffix to all text strings tagged with a particular character tag? That explains why you referred to regular expressions in the title of this thread. FrameMaker can use regular expression conventions to add a prefix and suffix to a found string, but only if that string was found by searching for a regular expression. A variation of the complex instructions in my previous suggestion would let you search for the character tag, then search for a regular expression consisting of the string you've already found, and then use regular expression conventions to add the prefix or suffix. Not something that would be very practical to repeat numerous times.

    This may be a good candidate for scripting.

        --Lynne