Thanks everyone for all the help getting me to this (hopefully) step. perl monks are truly wonderful. now, I know how to solve most of my problem. There is only one remaining problem: I want my substitution of balanced regexs not to contain the parens themselves. Of course, as always, this is easier to show than to describe.
/usr/bin/perl -w use strict; use warnings; use re 'eval'; use Regexp::Common; my $text= "start \\chapter{argument1}{argument2} end"; print "INPUT: $text\n"; ################################################################ my $arg1= qr/\s*($RE{balanced}{-parens=>'{ }'})/; my $args2= $arg1.$arg1; my $macronamereadfromfile="chapter"; my $patternreadfromfile= "<h1 tag=\"\$2\">\$1</h1>"; my $inpattern = "\\\\$macronamereadfromfile$args2"; my $outpattern = qq{ qq{$patternreadfromfile} }; #print "PATTERNS: '$inpattern'. to='$patternreadfromfile'. became='$ +outpattern'\n"; $text =~ s/$inpattern/$outpattern/gee; ################################################################ print "OUTPUT: '$text'\n\n";
I really want
OUTPUT: 'start <h1 tag="argument1">argument1</h1> end'
and not
OUTPUT: 'start <h1 tag="{argument1}">{argument1}</h1> end'
I could replace my pattern with a really unusual surrounding string in step 1 (e.g., @@$1@@) and then remove all '@@{' and '}@@' but this seems very ugly. there must be a simpler way. advice appreciated. regards, /iaw

In reply to Regexp::Common balanced curlies substitution by iaw4

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.