Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to replace a variable string within /* variable_string */ with x for each character in string?

Reply
Thread Tools

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

 
 
Victor
Guest
Posts: n/a
 
      09-11-2003
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
 
Reply With Quote
 
 
 
 
Matija Papec
Guest
Posts: n/a
 
      09-11-2003
X-Ftn-To: Victor

http://www.velocityreviews.com/forums/(E-Mail Removed) (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
 
Reply With Quote
 
 
 
 
Victor
Guest
Posts: n/a
 
      09-12-2003
Thanks Matija your help.
--Victor

Abigail <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)> ...
> Victor ((E-Mail Removed)) wrote on MMMDCLXIII September MCMXCIII in
> <URL:news:(E-Mail Removed) 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

 
Reply With Quote
 
Victor
Guest
Posts: n/a
 
      09-12-2003
Thanks Matija for your help.
--V

Matija Papec <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>. ..
> X-Ftn-To: Victor
>
> (E-Mail Removed) (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;

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Convert string with control character in caret notation to realcontrol character string. Bart Vandewoestyne C Programming 8 09-25-2012 12:41 PM
sed/awk/perl: How to replace all spaces each with an underscore thatoccur before a specific string ? bolega Python 6 08-23-2009 12:45 AM
How can I replace all occurrences of a character with another character in std string? herman C++ 5 08-30-2007 09:05 AM
8 bit character string to 16 bit character string Brand Bogard C Programming 8 05-28-2006 05:05 PM



Advertisments