in reply to Not matching a single quote (apostrophe!)

Using \Q$n\E in the regex instead of just $n should solve your problem. See perlre and quotemeta.

If it doesn't, please supply a short example by giving us the contents of the variables $tmp and $n at the point where it fails.

Perl 6 - links to (nearly) everything that is Perl 6.

Replies are listed 'Best First'.
Re^2: Not matching a single quote (apostrophe!)
by puddleglum (Initiate) on Nov 17, 2009 at 14:03 UTC

    Yes, I tried \Q$n\E but still fails

    $tmp contains some 27,000 lines, the entries with quotes fail

    e.g. King's Cross\tGreater London

    $n is exactly "King's Cross", for attempt 1, "King\'s Cross" for attempt 2.

    Note the brackets "Mayfair (north)" won't work in attempt 1 but will work in attempt 2 if I match "Mayfair \(north\)"

    so why not the quote????

      $tmp contains some 27,000 lines, the entries with quotes fail

      Then extract a line that should match, and doesn't, and show us that line.

      Perl 6 - links to (nearly) everything that is Perl 6.