View Full Version : charactor manipulation help
ignoranceisblis
01-19-2005, 06:56 AM
could anyone briefly describe a couple different ways of manipulating individual charactors within a string?
i.e. determining if a string has an "s" at the end of it, and removing it, then replacing it
and iand how could I say if ($string eq "<a href="any value">) then
$string = "the site URL"
any ideas?;
could anyone briefly describe a couple different ways of manipulating individual charactors within a string?
i.e. determining if a string has an "s" at the end of it, and removing it, then replacing it
and iand how could I say if ($string eq "<a href="any value">) then
$string = "the site URL"
any ideas?;
You could do this: s/s$//; which would replace any string with an "s" at the end of it. (only the "s");
if ($string eq = "<a href='whatever'>") {
$string = "site url";
}
andyede
01-19-2005, 10:20 AM
why do you want to remove the s then put it back on again?
simply check if its there and if not add it.
unless ( $string =~ m/s$/i ){
$string .= 's';
}
the first line tests to see if theres an s at the end and only goes so the second line if not. The 'i' at the end makes it ignor case. the second line just appends an s onto the end of the string with .=
if you do what to remove the s then use what Wig posted
$string =~ s/s$//;
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.