Charles,

Very nice indeed. I learned a lot with your example. Unfortunately, there
are a lot of situations where the lines wrap.

For example,

\backans{Now is the time for all good men to 
come to the aid of their country. The domain of
$f(x)=\sqrt{2x+3}$ is $\{x:\,x\ge -3/2\}$.}

Do you have similar good advice for the wrapping situation?

At 09:18 PM 6/29/04 -0500, Charles K. Clarkson wrote:
>David Arnold <[EMAIL PROTECTED]> wrote:
>
>: Suppose I have a number of lines in a latex file like this:
>: 
>: \backans{If $x=y^{2n}$ and $z=y^{3n}_{11}$, then we can
>: substitute to find a solution.} 
>: 
>: I'd like to scan the file and replace all of these with
>: this format:
>: 
>: \begin{answer}
>: If $x=y^{2n}$ and $z=y^{3n}_{11}$, then we can substitute
>: to find a solution.
>: \end{answer}
>: 
>: I'm looking for suggestions as to how to make this change
>: with my perl script. I am puzzled by the use of nested
>: braces and how I can be sure I've got everything between
>: the opening and closing brace.
>
>    As long as the lines do not wrap, you don't need to
>worry about the nesting. Perl regexes are greedy by
>default. So '.+' will try to suck in the longest match
>possible. Which is just what you want.
>
>while ( <DATA> ) {
>    printf "\\begin{answer}\n%s\n\\end{answer}\n", $1 if /^\\backans{(.+)}/;
>}
>
>__END__
>\backans{If $x=y^{2n}$ and $z=y^{3n}_{11}$, then we can ...}
>\backans{If $x=y^{2n}$ and $z=y^{3n}_{11}$, then we can ...}
>\backans{If $x=y^{2n}$ and $z=y^{3n}_{11}$, then we can ...}
>\backans{If $x=y^{2n}$ and $z=y^{3n}_{11}$, then we can ...}
>
>
>HTH,
>
>Charles K. Clarkson
>-- 
>Mobile Homes Specialist
>254 968-8328
>
>
>

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to