in reply to Re: Replace strings with "("
in thread Replace strings with "("

The objective is to replace the following string:

test("test

with test("GC_test

i.e. put GC_ before the second "test". Hope that answers your query.

As well backslashing the open paren didn't work. That was my initial solution. But I did try your suggestion but no luck.

Please help; and thanks

Replies are listed 'Best First'.
Re^3: Replace strings with "("
by punkish (Priest) on Jan 30, 2005 at 02:15 UTC
    #!/usr/bin/perl -w use strict; my $str_in = 'test("test'; my $str_out = $str_in; #$str_out =~ s/"t/"GC_t/; $str_out =~ s/"/"GC_/; print "string 1: $str_in\n"; print "string 2: $str_out\n";

    produces

    string 1: test("test string 2: test("GC_test

    Am I missing something here?

    Update: Just match the double quote (original match commented out above). That works just well, assuming there is only one double quote in the string.