Note that the string '([^|]*)(\|)([^|]*)' also successfully parses '|' '||' '|||'
c:\@Work\Perl\monks>perl -wMstrict -le "use Data::Dump qw(pp); ;; my $rx_string = '([^|]*)(\|)([^|]*)' ; ;; for my $s ( 'Thanos1983+|', 'Thanos1983+| ', 'Thanos1983+| ', 'Thanos1983+|Thanos1983+', '|Thanos1983+', ' |Thanos1983+', ' |Thanos1983+', '+++|+++', '|', '||', '|||', ) { my $parsed = my @captured = $s =~ $rx_string; if ($parsed) { print qq{'$s' -> }, pp \@captured; } else { print qq{failed to parse '$s'}; } } " 'Thanos1983+|' -> ["Thanos1983+", "|", ""] 'Thanos1983+| ' -> ["Thanos1983+", "|", " "] 'Thanos1983+| ' -> ["Thanos1983+", "|", " "] 'Thanos1983+|Thanos1983+' -> ["Thanos1983+", "|", "Thanos1983+"] '|Thanos1983+' -> ["", "|", "Thanos1983+"] ' |Thanos1983+' -> [" ", "|", "Thanos1983+"] ' |Thanos1983+' -> [" ", "|", "Thanos1983+"] '+++|+++' -> ["+++", "|", "+++"] '|' -> ["", "|", ""] '||' -> ["", "|", ""] '|||' -> ["", "|", ""]
Give a man a fish: <%-{-{-{-<
In reply to Re^3: Split string in groups with non white space using regex
by AnomalousMonk
in thread Split string in groups with non white space using regex
by thanos1983
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |