Perl:String Functions
Jump to navigation
Jump to search
The methods and properties of the String type include:
Example | Value | Comment |
---|---|---|
$s." once" | "Andrew was here once" | The strings are concatenated using . |
$s eq "another" | false | Tests for equality - use ne for not equals |
index($s,"was") | 7 | Returns -1 if the substring is not there. |
length($s) | 15 | The number of characters |
split(" ",$s) | ("Andrew","was","here") | Returns an array of String. |
substr($s,2,7) | "drew" | Characters from position 2 to just before 7 |
uc($s) | "ANDREW WAS HERE" | Also lc() |