Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   How to replace a variable string within /* variable_string */ with x for each character in string? (http://www.velocityreviews.com/forums/t882440-how-to-replace-a-variable-string-within-variable_string-with-x-for-each-character-in-string.html)

Victor 09-11-2003 06:49 PM

How to replace a variable string within /* variable_string */ with x for each character in string?
 
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

Matija Papec 09-11-2003 07:29 PM

Re: How to replace a variable string within /* variable_string */ with x for each character in string?
 
X-Ftn-To: Victor

gvictor97@yahoo.com (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

Victor 09-12-2003 04:18 PM

Re: How to replace a variable string within /* variable_string */ with x for each character in string?
 
Thanks Matija your help.
--Victor

Abigail <abigail@abigail.nl> wrote in message news:<slrnbm1u0o.6v3.abigail@alexandra.abigail.nl> ...
> Victor (gvictor97@yahoo.com) wrote on MMMDCLXIII September MCMXCIII in
> <URL:news:ab759f.0309111049.48aafe05@posting.googl e.com>:
> ^^ 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 09-12-2003 04:19 PM

Re: How to replace a variable string within /* variable_string */ with x for each character in string?
 
Thanks Matija for your help.
--V

Matija Papec <mpapec@yahoo.com> wrote in message news:<16j1mvoj9dvddd3ehdovma1ke10hnn3o0m@4ax.com>. ..
> X-Ftn-To: Victor
>
> gvictor97@yahoo.com (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;



All times are GMT. The time now is 03:52 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57