in reply to regex to remove a word from string
As this is your tenth post, I feel someone ought to help you out by pointing you to Writeup Formatting Tips. Well formatted posts get better answers.
The following code does what it seems that you're asking.
my $str = "auth_plugin_stack = a,b,EXT::USCC::USCCAuth,c,d"; $str =~ s/,EXT::USCC::USCCAuth(?=,)//; print "$str\n";
This prints the following output:
auth_plugin_stack = a,b,c,d
If the literal string "EXT::USCC::USCCAuth" is too specific when used as a pattern, you might need to explain what additional challenges you're facing.
Between perlintro and perlretut, you should have adequate ammunition to bag this task, unless there's more to it than you've told us.
By the way, this string looks like it might have come from a CSV file. If that's the case, you may be happy to discover Text::CSV and Text::CSV_XS.
Update: Wait a second... I feel duped here. Your profile says "PERL developer having 5+ years exp." Surely there's more to your question than how to construct a regular expression consisting entirely of a literal string. A Perl developer claiming 5+ years of experience must have a deeper question than this. What are we missing that we need to be told, in order to provide a useful answer to the sort of question that someone of your experience would ask?
Dave
|
|---|