in reply to substitution with exceptions

Looks like you want a Negative Lookbehind Assertion:

(?<!foo) Negative Lookbehind Asserts that what immediately precedes the current position in the string is not foo

update

maybe try s/(?<!\bisn)(?<!\baren)'t/ 't/g

\b ensures a word boundary.

(actually in order to play save you should also check for a trailing boundary 't\b

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Replies are listed 'Best First'.
Re^2: substitution with exceptions
by choroba (Cardinal) on Sep 27, 2018 at 19:27 UTC
    Negative look-behind only works for fixed length patterns, "aren" and "isn" are of different lengths.
    (?<!n)'t
    might work, but if you need to exclude both, you can't use
    (?<!aren|isn)'t Variable length lookbehind not implemented in regex m/(?<!aren|isn)'t/
    You can specify them one by one, though:
    (?<!aren)(?<!isn)'t
    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
      Tsk, you replied to the king of updates without checking ?

      ;-p

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Re^2: substitution with exceptions
by haukex (Archbishop) on Sep 27, 2018 at 19:31 UTC
Re^2: substitution with exceptions
by Anonymous Monk on Sep 27, 2018 at 20:08 UTC

    WOW. It works perfectly.