in reply to Regex. Combination of words block. Need help.

Why that array? Id use split
  • Comment on Re: Regexp. Combination of words block. Need help.

Replies are listed 'Best First'.
Re^2: Regexp. Combination of words block. Need help.
by nickwest (Initiate) on Feb 09, 2020 at 11:23 UTC
    $b = 'aaa,bbb,ccc ddd; eee fff, kv.6 end'; @a = split(/[\s\,\.\;]+/, $b); for ($i=0;$i<$#a-1;$i++) { $_ = $b; $k = $a[$i]; s/^.*$k[\s\,\.\;]+//; push @c, $_; } push @a, @c, $b; foreach (@a) { print "$_\n"; }

    and get:
    aaa bbb ccc ddd eee fff kv 6 end bbb,ccc ddd; eee fff, kv.6 end ccc ddd; eee fff, kv.6 end ddd; eee fff, kv.6 end eee fff, kv.6 end fff, kv.6 end kv.6 end 6 end aaa,bbb,ccc ddd; eee fff, kv.6 end
Re^2: Regexp. Combination of words block. Need help.
by nickwest (Initiate) on Feb 09, 2020 at 11:30 UTC
    Yes! Thank you! I'm going by your way. Firstly split! But I think it's possible make by one regex.