Author Topic: Find and replace on keyword ending in ! or ? does not work with "whole words"  (Read 2536 times)

Offline brightwolf

  • Newcomer
  • *
  • Posts: 4
    • View Profile
Today it struck my eye that find and replace on a keyword that's ending in an exclamation mark (!) or question mark (?) does not work with "whole words" option selected. Deselecting "whole words" makes this work. But there's no space between the mark and the word, so should not this work? Is this the expected behaviour?

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 25020
    • View Profile
    • Camera Bits, Inc.
Today it struck my eye that find and replace on a keyword that's ending in an exclamation mark (!) or question mark (?) does not work with "whole words" option selected. Deselecting "whole words" makes this work. But there's no space between the mark and the word, so should not this work? Is this the expected behaviour?

Can you provide specific examples, and a screen shot of the Find and Replace panel, please?  Use the 'Attachments and other options' link when you're composing your reply to this message and there you'll be able to upload your JPEG format screenshot.

Also, can you list the actual metadata in the fields you expect to match and end up replacing?

Thanks,

-Kirk

Offline brightwolf

  • Newcomer
  • *
  • Posts: 4
    • View Profile
Hi Kirk,

Please find the requested examples attached:
screenshot 1: the keyword panel showing the keyword I intend to change ("ValleyoftheKings?")
screenshot 2: The Find and Replace panel with the option "Whole words" selected
screenshot 3: The result of that find and replace (NOK)
screenshot 4: The Find and Replace panel with the option "Whole words" deselected
screenshot 5: The result of that find and replace (OK)

I suspect now that PMP uses a regex to execute the find and replace if the option "whole words" has been selected, but that it does not escape the question mark and other characters that are relevant for regex (such as the exclamation mark, the dot and so on) in that case. When I replaced the question mark in this example with a dot, then the same find and replace did not work. Could this be the case?

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 25020
    • View Profile
    • Camera Bits, Inc.
Hi Kirk,

Please find the requested examples attached:
screenshot 1: the keyword panel showing the keyword I intend to change ("ValleyoftheKings?")
screenshot 2: The Find and Replace panel with the option "Whole words" selected
screenshot 3: The result of that find and replace (NOK)
screenshot 4: The Find and Replace panel with the option "Whole words" deselected
screenshot 5: The result of that find and replace (OK)

I suspect now that PMP uses a regex to execute the find and replace if the option "whole words" has been selected, but that it does not escape the question mark and other characters that are relevant for regex (such as the exclamation mark, the dot and so on) in that case. When I replaced the question mark in this example with a dot, then the same find and replace did not work. Could this be the case?

A regex is only used when you set the "Grep" option.  "Whole words" does not itself use a regex.  But punctuation is a word separator so "ValleyoftheKings?" is two words: "ValleyoftheKings" and "?".

-Kirk