How to extract a number from a string in Perl?

Viewed 79514

I have

print $str;
abcd*%1234$sdfsd..#d

The string would always have only one continuous stretch of numbers, like 1234 in this case. Rest all will be either alphabets or other special characters.

How can I extract the number (1234 in this case) and store it back in str?

This page suggests that I should use \d, but how?

4 Answers
Related