in reply to Re^2: Perl-Replacement of comma in between the matched Patterns
in thread Perl-Replacement of comma in between the matched Patterns

You still haven't explained what "failed in other cases" means.

It's hard to read in your one-liner (have you tried adding the /x flag to your regexp which allows you to write it over multiple lines, with comments?), but in your second statement it sure seems like you are replacing anything that matches ,(?=[^\[\]]*\[*\{*\}*\]) with | ... you probably need to learn about extracting matches, too.

Remember: Ne dederis in spiritu molere illegitimi!

Replies are listed 'Best First'.
Re^4: Perl-Replacement of comma in between the matched Patterns
by cdkumar (Initiate) on Jul 09, 2015 at 05:26 UTC

    Many thanks for your inputs and advice. I dont have much expertise on the Perl Regular Expression. I need to do this using substitute operator, So I am looking for help. Let me put my requirement in a simple way.

    (1,2,4,{8,9,xy{4343,0943},pq[{434,5454}]},4,6)

    Replacement #1

    Need to replace commas in the pattern xy{4343,0943} with pipe to get xy{4343|0943}

    Replacement #2

    Need to replace commas in the pattern pq[{434,5454}] with pipe to get pq[{434|5454}]

    Please suggest