in reply to Regexp matched part to lower case

The following code:
use strict; use warnings; my $string = "aDescriptor.Type = {\@see Star.Awt.Win#TOP}"; print( "Original:$string\n" ); $string =~ s/ {\@see\s+((\w+\.)+)(\w+)\#(\w+)} / "<idl package=\"" . lc($1) . "\" name=\"$3\" anker=\"$4\">" /gex; print( "Updated:$string\n" );

..produces the following output..

Original:aDescriptor.Type = {@see Star.Awt.Win#TOP} Updated:aDescriptor.Type = <idl package="star.awt." name="Win" anker=" +TOP">

Update: holli has the best answer below. I suspected there was an in-place capitalisation modifier, and clearly this is the best solution.

Replies are listed 'Best First'.
Re^2: Regexp matched part to lower case
by holli (Abbot) on Jun 02, 2005 at 09:53 UTC
    There's no need for the /e mofier.
    my $string = "aDescriptor.Type = {\@see Star.Awt.Win#TOP}"; $string =~ s/{\@see\s+((\w+\.)+)(\w+)#(\w+)}/<idl package="\L$1\E" nam +e="$3" anker="$4" \/>/g;


    holli, /regexed monk/