
Jasmine
Administrator
/ Moderator
Feb 16, 2002, 8:00 PM
Post #2 of 2
(1020 views)
|
Re: [Alain] First 4 characters of a string
[In reply to]
|
Can't Post
|
|
[url=http://www.perldoc.com/perl5.6.1/pod/func/substr.html]substr is your friend. It will allow you to extract any number of characters from a string. It works like this:
# start at, stop at, replace with (if anything) my $first_4 = substr $var, 0, 4, 'newtext'; In your scenario, you can use substr like this to get what you need: [perl]my $var = "21f2.albumimage.jpg"; my $first_4 = substr $var, 0, 4; print $first_4;[/perl]
|