http://www.perlmonks.org?node_id=513002


in reply to Re: Escaping quotemeta() in regex
in thread Escaping quotemeta() in regex

Exactley, this is why I ask if there may be someway to tell quotemeta the this protion of the string should not be escaped because it contains valid expression metacharacters.

Sweetblood

Replies are listed 'Best First'.
Re^3: Escaping quotemeta() in regex
by ikegami (Patriarch) on Nov 30, 2005 at 18:24 UTC
    What distinguishes the portion that should be escaped from the portion that shouldn't be?
      That's my question :)

      Sweetblood

        My first post in this thread pointed out there is NO inherent distinction. Any distinction would have to be imposed by you, the designer. Any distinction we come up with would be arbitrary and thus have limitations, so we can't answer your question.

        We really can't help you until you explain what \dth\d\file.txt should become.

        • Should the first "\" should be escaped?
          • Yes? What if the user wants to match "4th..." and "5th...", but not "\dth..."?
          • No? What if the user wants to match "\dth...", but not "4th..." and "5th..."?
        • Should the second "\" should be escaped?
          • Yes? What if the user wants to match "...th4..." and "...th5...", but not "...th\d..."?
          • No? What if the user wants to match "...th\d...", but not "...th4..." and "...th5..."?
        • Should the "." should be escaped?
          • Yes? What if the user wants to match "...file_txt"?
          • No? What if the user doesn't want to match "...file_txt"?

        We can show you how if you tell us what you want, but you haven't given us nearly enough information.