Reputation: 2243
I want to extract the number from a file name.
For example, from "i2mage001.png
", I want to extract "i2mage
" and "001
".
I do not know if it will always be the last three numbers which I want to extract. It will be sufficient if I can just extract the numbers, although a regular expression to extract the "i2mage
" would also be helpful
Upvotes: 0
Views: 166
Reputation: 424983
This regex matches the digits part (without groups - ie the entire match is your target):
\d+(?=\.)
See live demo.
And this matches the part before that (ie i2image
in your example):
.*\D(?=\d+\.)
See live demo.
Upvotes: 2