in reply to Re: Advanced replace function
in thread Advanced replace function
You are advocating building small patterns so that they can be combined into larger patterns, right? If so, your code is buggy (and I don't mean just the superfluous (?:)).
>perl -E"$sqr=qr/\[.*?\]/; $_='ab[cd]ef[gh]'; s/$sqr$//; say" ab
Fixed:
>perl -E"$sqr=qr/\[[^\[\]]*\]/; $_='ab[cd]ef[gh]'; s/$sqr$//; say" ab[cd]ef
|
|---|