in reply to regex to remove a word from string
An alternative using splits and joins.
$ perl -Mstrict -Mwarnings -E ' my @strings = ( q{auth_plugin_stack = EXT::USCC::USCCAuth}, q{auth_plugin_stack = a,b,EXT::USCC::USCCAuth,c,d}, q{auth_plugin_stack = a,b,EXT::USCC::USCCAuth}, q{auth_plugin_stack = EXT::USCC::USCCAuth,c,d}, ); foreach my $string ( @strings ) { my( $left, $right ) = split m{ = }, $string; say join q{ = }, $left, join q{,}, grep { $_ ne q{EXT::USCC::USCCAuth} } split m{,}, $right; }' auth_plugin_stack = auth_plugin_stack = a,b,c,d auth_plugin_stack = a,b auth_plugin_stack = c,d $
I hope this is of interest.
Cheers,
JohnGG
|
|---|