Jump to content
You must now use your email address to sign in [click for more info] ×

Searching for a specific word


Recommended Posts

Maybe there's a way to do this already, and I assume it can be done using regular expressions, but I'd like an easier way to do this as I need to do it all the time.

When searching for a specific word, there's no easy way to search for a word by itself. For example, I was looking for the word par. As you might imagine in a large text that shows up many times in other words like part, separate, party, depart, apartment, etc. I want to find it only when it's by itself. I can try adding a space before and after it, but that won't find it if there is a comma, period, parenthesis, or quote. In fact, it won't find it even if there's a footnote after it (I don't think footnote numbers should affect searches - so suggestion to fix that as well).

I'd like it so if I search for par and click a checkbox for finding the whole word, it would find it no matter what other non-letter characters are on either side of it.

Bonus if you can turn on and off variant search as well (finding plural and singular, adjective and adverb forms, etc.)

Link to comment
Share on other sites

Hi @philipt18 

The easy and straightforward solution for everyone:

image.png.9f7050743db376c7b09fadc0d351579f.png

This does replace WORD even if if there is a comma, period, parenthesis, or quote before or after the word: "WORD" ,WORD. (WORD)

Regular expressions are something I have developers create for me, but slowly I've accumulated an arsenal of variations that I can adapt for my own use. They are complex, but can really be powerful when you truly need tricks.

image.png.b22bc9ef39fa890b03d7b60ed815e0ab.png

To create a regular expression (regex) that matches the word "par" as a standalone word in a text, regardless of the surrounding punctuation or special characters, you can use the following regex expression. This regex will match "par" when it appears by itself, even if it's followed by a comma, period, parenthesis, or other non-letter characters.

\bpar\b

It will look like this in the search replace dialog:

image.png.1c57cfad4e7a60926ea224e8a5dcdffd.png

Regarding the bonus request for variant search (like finding plural, singular, adjective, and adverb forms), regular expressions are not inherently equipped to handle linguistic variations. To achieve this, you'd typically need a more advanced text processing tool or library that understands language context and morphology. However, a basic approach could be to list the variations explicitly in the regex, separated by a pipe | which acts as an "OR" operator. For example, if you want to find "par", "pars", and "pare" (imaginary variants for illustration), you could use:

\b(par|pars|pare)\b

I hope this helps. 🙂

Experienced Quality Assurance Manager - I strive for excellence in complex professional illustrations through efficient workflows in modern applications, supporting me in achieving my and my colleagues' goals through the most achievable usability and contemporary, easy-to-use user interfaces.

 

Link to comment
Share on other sites

Ah, a linguistic replacement? I believe we're on the brink of what DTP programs are expected to offer in terms of attractive features, but let's see what AI makes the new normal in the not-too-distant future. As long as one can easily specify something that yields a predictable result. It's likely to become more popular with the general public and customer base than regex.

Experienced Quality Assurance Manager - I strive for excellence in complex professional illustrations through efficient workflows in modern applications, supporting me in achieving my and my colleagues' goals through the most achievable usability and contemporary, easy-to-use user interfaces.

 

Link to comment
Share on other sites

2 minutes ago, Bit Arts said:

Ah, a linguistic replacement? I believe we're on the brink of what DTP programs are expected to offer in terms of attractive features, but let's see what AI makes the new normal in the not-too-distant future. As long as one can easily specify something that yields a predictable result. It's likely to become more popular with the general public and customer base than regex.

 

Actually I just meant the whole word searching without needing to use regex. However, Publisher already does do some minor linguistic replacement when, for example, you type in a plural word when adding a marker, if the singular of the word exists as an index topic, it will still suggest it. I would guess it's not using any fancy AI to do this, just simply searching for words without -s or -es at the end, but even that can be helpful sometimes.

Link to comment
Share on other sites

4 minutes ago, philipt18 said:

Actually I just meant the whole word searching without needing to use regex. However, Publisher already does do some minor linguistic replacement when, for example, you type in a plural word when adding a marker, if the singular of the word exists as an index topic, it will still suggest it. I would guess it's not using any fancy AI to do this, just simply searching for words without -s or -es at the end, but even that can be helpful sometimes.

image.png.6e2162fbce8c7cfb299bd613f8d88374.png

"This does replace WORD even if if there is a comma, period, parenthesis, or quote before or after the word: "WORD" ,WORD. (WORD)"

This worked for me without regex. 🙂

Experienced Quality Assurance Manager - I strive for excellence in complex professional illustrations through efficient workflows in modern applications, supporting me in achieving my and my colleagues' goals through the most achievable usability and contemporary, easy-to-use user interfaces.

 

Link to comment
Share on other sites

5 hours ago, philipt18 said:

although still a lot of work when doing things like indexing hundreds of words

Can't you do that searching via the Index panel, rather than Find and Replace?

In any case, if you choose Whole Word from the format menu for the Find field, it should be remembered for you.

-- Walt
Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases
PC:
    Desktop:  Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 

    Laptop:  Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
iPad:  iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard 
Mac:  2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1

Link to comment
Share on other sites

30 minutes ago, philipt18 said:

That's helpful, although it doesn't work if there is a footnote number after the word, which I guess is a bug.

It sure sounds like a bug.

I can only recommend that you report it here (macOS) or maybe here (Win).

Experienced Quality Assurance Manager - I strive for excellence in complex professional illustrations through efficient workflows in modern applications, supporting me in achieving my and my colleagues' goals through the most achievable usability and contemporary, easy-to-use user interfaces.

 

Link to comment
Share on other sites

1 hour ago, walt.farrell said:

Can't you do that searching via the Index panel, rather than Find and Replace?

In any case, if you choose Whole Word from the format menu for the Find field, it should be remembered for you.

 

If you're trying to search the text so you can add instances to the index, then searching in the index doesn't help you.

Link to comment
Share on other sites

2 hours ago, philipt18 said:

If you're trying to search the text so you can add instances to the index, then searching in the index doesn't help you.

If you select a word in the Index panel, there is a Find option to find all other occurrences of the word in that .afpub file, where you can then optionally add them to the Index.

-- Walt
Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases
PC:
    Desktop:  Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 

    Laptop:  Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
iPad:  iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard 
Mac:  2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1

Link to comment
Share on other sites

29 minutes ago, walt.farrell said:

If you select a word in the Index panel, there is a Find option to find all other occurrences of the word in that .afpub file, where you can then optionally add them to the Index.

 

I forgot about that one, thanks. Interestingly that search finds words with footnotes after them, while the main search does not.

Link to comment
Share on other sites

One downside of this feature is that I someone put explanations in parenthesis after my index topics, and this feature obviolusly doesnt work in that case. I need to remove that, do the search, then put it back. It might be nice to have an index topic, and a 'Display as' field to allow you to modify how it's displayed.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.