Regex 带分隔符前缀的Perl分割正则表达式
如果没有特殊字符,我想在分隔符前面拆分ifRegex 带分隔符前缀的Perl分割正则表达式,regex,perl,split,Regex,Perl,Split,如果没有特殊字符,我想在分隔符前面拆分if my $str = "a,b,c,d,e"; my @lst = split (/,/, $str); # gives me: ("a", "b", "c", "d", "e") # now I want to split after any , with not a character c in front of the ,. # ("a", "b", "c,d", "e") 我试过了 split (/(?!c),/, $str) 但它没有按
my $str = "a,b,c,d,e";
my @lst = split (/,/, $str);
# gives me: ("a", "b", "c", "d", "e")
# now I want to split after any , with not a character c in front of the ,.
# ("a", "b", "c,d", "e")
我试过了
split (/(?!c),/, $str)
但它没有按预期工作。用于向后检查的功能
split (/(?<!c),/, $str)
split(/(?)?