How to replace a variable string within /* variable_string */ with x for each character in string?

Discussion in 'Perl Misc' started by Victor, Sep 11, 2003.

  1. Victor

    Victor Guest

    How to replace a variable string within /* variable_string */ with x
    for each character in string?

    The string may span on multiple lines.

    for eaxmple:

    /* string */ ->
    /* xxxxxx */

    /* stringstring */ ->
    /* xxxxxxxxxxxx */

    /* string1
    string2
    */ ->

    /* xxxxxxx
    xxxxxxx
    */

    Thanks,
    Victor
     
    Victor, Sep 11, 2003
    #1
    1. Advertising

  2. Victor

    Matija Papec Guest

    X-Ftn-To: Victor

    (Victor) wrote:
    >How to replace a variable string within /* variable_string */ with x
    >for each character in string?
    >
    >The string may span on multiple lines.
    >
    >for eaxmple:
    >
    >/* string */ ->
    >/* xxxxxx */
    >
    >/* stringstring */ ->
    >/* xxxxxxxxxxxx */
    >
    >/* string1
    > string2
    >*/ ->
    >
    >/* xxxxxxx
    > xxxxxxx
    >*/


    $code =~ s{/\*(.+?)\*/}{
    (my $com = $1) =~ s/\S/x/g;
    "/*$com*/";
    }ges;


    --
    Matija
     
    Matija Papec, Sep 11, 2003
    #2
    1. Advertising

  3. Victor

    Victor Guest

    Thanks Matija your help.
    --Victor

    Abigail <> wrote in message news:<>...
    > Victor () wrote on MMMDCLXIII September MCMXCIII in
    > <URL:news:>:
    > ^^ How to replace a variable string within /* variable_string */ with x
    > ^^ for each character in string?
    > ^^
    > ^^ The string may span on multiple lines.
    > ^^
    > ^^ for eaxmple:
    > ^^
    > ^^ /* string */ ->
    > ^^ /* xxxxxx */
    > ^^
    > ^^ /* stringstring */ ->
    > ^^ /* xxxxxxxxxxxx */
    > ^^
    > ^^ /* string1
    > ^^ string2
    > ^^ */ ->
    > ^^
    > ^^ /* xxxxxxx
    > ^^ xxxxxxx
    > ^^ */
    >
    >
    > use Regexp::Common;
    >
    > $str =~ s{$RE{comment}{C}{-keep}}{my $x = $3; $x =~ s!\S!x!g; "/*$x*/"}ge;
    >
    >
    > Abigail
     
    Victor, Sep 12, 2003
    #3
  4. Victor

    Victor Guest

    Thanks Matija for your help.
    --V

    Matija Papec <> wrote in message news:<>...
    > X-Ftn-To: Victor
    >
    > (Victor) wrote:
    > >How to replace a variable string within /* variable_string */ with x
    > >for each character in string?
    > >
    > >The string may span on multiple lines.
    > >
    > >for eaxmple:
    > >
    > >/* string */ ->
    > >/* xxxxxx */
    > >
    > >/* stringstring */ ->
    > >/* xxxxxxxxxxxx */
    > >
    > >/* string1
    > > string2
    > >*/ ->
    > >
    > >/* xxxxxxx
    > > xxxxxxx
    > >*/

    >
    > $code =~ s{/\*(.+?)\*/}{
    > (my $com = $1) =~ s/\S/x/g;
    > "/*$com*/";
    > }ges;
     
    Victor, Sep 12, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brand Bogard

    8 bit character string to 16 bit character string

    Brand Bogard, May 25, 2006, in forum: C Programming
    Replies:
    8
    Views:
    748
    those who know me have no need of my name
    May 28, 2006
  2. herman
    Replies:
    5
    Views:
    7,633
    =?ISO-8859-1?Q?Erik_Wikstr=F6m?=
    Aug 30, 2007
  3. bolega
    Replies:
    6
    Views:
    2,083
  4. MSUTech

    Check Each Character of a String?

    MSUTech, Jul 11, 2005, in forum: ASP General
    Replies:
    9
    Views:
    203
    Dave Anderson
    Jul 12, 2005
  5. Bart Vandewoestyne
    Replies:
    8
    Views:
    762
    Bart Vandewoestyne
    Sep 25, 2012
Loading...

Share This Page