Thanks to all those who have offered their help.

I think I failed to make something clear.  John's script below replaces
everything within the brackets.  What I need is to selectively replace only
certain characters when they appear in a string within brackets.  So if I
have:

Don't Match the capital M unless {the M is inside brackets} then Match it

I need to be able to change the M inside the brackets in such a way that the
entire line is output, but with, in this case, the single change that the
one M within the brackets has been changed to another character, say an X,
so that the line would now read:

Don't Match the capital M unless {the X is inside brackets} then Match it

I need to process a very large file in this way, and there are about a dozen
different single characters what would have to be systematically changed to
an alternative character.  Actually, what I want to do is change the M, for
instance, to the Unicode character U+1E43.  I've been able to apply these
changes to the file as a whole, but don't know how to apply them only to
certain characters that appear in text within brackets.

I was assuming (wrongly?) that I would have to set up some kind of loop to
run through each string within brackets to test for the M (and a number of
other characters) and change it to the U+1E43 (an a number of other Unicode
characters) if found.  Can I do all this just using regular expressions with
s/// or tr///?

I hope this is more clear.  Thanks again to everyone who has offered help.

David


"John W. Krahn" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> David Carpenter wrote:
> >
> > This is a list for beginners, right?  So perhaps no one will be too
annoyed
> > if I ask what is probably a really stupid question . . .
> >
> > I have a text file with occasional strings enclosed in braces:
> > kdkdkiwiwdkdkdk {iwidkwidkw} kdkdkdwiwiwkdkdk . . .
> >
> > I would like to use tr/// to modify the characters within the braces,
while
> > leaving the rest of the file unchanged.  Whlie I'm sure this is a
staight
> > forward procedure, I've tried a number of loops and can't get it to
work.
> > If anyone could point a beginner in the right direction, he'd appreciate
it.
>
>
> Something like this for example:
>
> while ( <FILE> ) {
>
>     s[
>         {          # match beginning brace
>         (.*?)      # store non-greedy match in $1
>         }          # match ending brace
>     ][
>         ( $a = $1 ) =~            # can't modify $1
>         tr/a-zA-Z/n-za-mN-ZA-M/;  # do rot13 on match
>         $a         # use the results in substitution
>     ]xe;           # x for whitespace and comments
>                    # e to run the tr///
>
>     } # end of while loop
>
>
>
> John
> --
> use Perl;
> program
> fulfillment



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to