| Welcome to WebmasterWorld Guest from 184.108.40.206 |
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
|Become a Pro Member|
|using regex to extract data |
or any other method ...
How can I extract the number 19 from the string product_27001_th19.jpg . The solution needs to be dynamic, as the function should return 19 for all the following:
I am perl programmer and not sure how to do this in php.
1) Do you want it in PHP or Perl? This is a Perl forum.
2) What do you want to do with 19 later? If you just want to extract 19 whats the point? It'a always 19...
Am I missing something?
If '19' appers only before dot that separates filename from extention than you may try this code in perl:
my ($number) = $filename =~ m/(\d+)\.[^.]+$/;
Here $filename must contain your filename, and $number receives '19' or any other number that was in filename.
update: oops, you wish to do that in php....
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved