Brent Clark [BC], on Thursday, June 02, 2005 at 12:33 (+0200)
contributed this to our collective wisdom:

BC> Im trying to get the numbers before the hyphen

BC> e.g.
BC> 75664545-bookings
BC> Can I use index() for this ?

yes, you can use index for find index of "-" and after using substr to
extract that.
perldoc -f index
perldoc -f substr

but power of perl is in regular expressions, so I'd use them:

my ($result) = "75664545-bookings" =~ /([^-]+)/;

^^-- extract everything to $result what is before "-"
if extracted part is always numbers I should use:

my ($result) = "75664545-bookings" =~ /(\d+)-/g;

-- 

How do you protect mail on web? I use http://www.2pu.net

[I sure get a kick outta that Beavis & Butthead show! -Primus]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to