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


In reply to Re: regex to remove a word from string by davido
in thread regex to remove a word from string by upaksh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.