in reply to Re^4: Regex with Backslashes
in thread Regex with Backslashes

It's a META-LANGUAGE PROBLEM!! Everyone DUCK!!! ............................ quack, quack

Here's a third way of quoting that, unlike ' and " completely disables the special properties of \.
It's a version of a "here-document" and it's documented in perlop.

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11116857 use warnings; my $text = <<'END'; # this quoting method disables special properties +of \ 1,Something\,\\text\\text\0x2B,X,99,\,\\,\\\,foobar END chomp $text; print "input:\n$text\n"; my @fields = split /(?<!\\),|(?<=\\\\),/, $text; print "\noutput:\n"; for ( @fields ) { print "$_\n"; }

Outputs:

input: 1,Something\,\\text\\text\0x2B,X,99,\,\\,\\\,foobar output: 1 Something\,\\text\\text\0x2B X 99 \,\\ \\\ foobar

Is this output a correct solution to your problem?

Replies are listed 'Best First'.
Re^6: Regex with Backslashes
by anita2R (Scribe) on May 18, 2020 at 19:17 UTC

    Yes !!! That is a correct solution.

    I would never have thought of using a 'here document' for this.

    Now I have to decide whether to stay with my original scheme with 1,Text\, more text\\,X,99 or go with what I said in response to haukex.