| Welcome to WebmasterWorld Guest from 22.214.171.124 |
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
|using regex to extract data |
or any other method ...
| 1:22 am on Sep 11, 2003 (gmt 0)|
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:40 am on Sep 11, 2003 (gmt 0)|
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?
| 8:13 am on Sep 11, 2003 (gmt 0)|
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.
© Webmaster World 1996-2013 all rights reserved