
Jasmine
Administrator
/ Moderator
Jan 24, 2000, 6:30 PM
Post #2 of 3
(266 views)
|
|
Re: Extracting a character from a variable
[In reply to]
|
Can't Post
|
|
Just use the substr (substring) function, which uses the following format: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> $extracted = substr(STRING,POSITION,LENGTH); </pre><HR></BLOCKQUOTE> The STRING is pretty self explanatory -- that's the string that you want to extract characters from. POSITION is the starting point of extraction from the string. The count starts at 0, not 1. LENGTH is the number of characters to extract. Example: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> $string = "Perl is cool."; $extracted = substr($string,5,2); # $extracted contains "is" </pre><HR></BLOCKQUOTE> Good luck!
|