parsifal has asked for the wisdom of the Perl Monks concerning the following question:
$instring = "This-is-my-string";
$outstring = "";
for ($i=0; $i length $instring; $i++)
{
if ($instring[$i] ne "-")
{
$outstring .= $instring[$i];
}
else
{
# replace with a new character or substring
$outstring .= "_";
}
}
print "$outstring";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: string manipulation
by indigo (Scribe) on Mar 29, 2001 at 22:43 UTC | |
by indapa (Monk) on Mar 30, 2001 at 00:59 UTC | |
|
(tye)Re: string manipulation
by tye (Sage) on Mar 29, 2001 at 23:35 UTC | |
|
Re: string manipulation
by Xxaxx (Monk) on Mar 30, 2001 at 00:57 UTC | |
|
Re: string manipulation
by tune (Curate) on Mar 29, 2001 at 22:44 UTC | |
by Desdinova (Friar) on Mar 29, 2001 at 23:09 UTC | |
by Xxaxx (Monk) on Mar 30, 2001 at 01:15 UTC | |
by extremely (Priest) on Mar 30, 2001 at 03:31 UTC | |
by Xxaxx (Monk) on Mar 30, 2001 at 03:56 UTC | |
| |
by Desdinova (Friar) on Mar 30, 2001 at 03:57 UTC | |
|
Re (tilly) 1: string manipulation
by tilly (Archbishop) on Mar 30, 2001 at 04:33 UTC |