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

V

Victor

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
 
M

Matija Papec

X-Ftn-To: Victor

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;
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top