Reputation: 2043
I have a string like this
file-myfle_20130207_094852am.csv
how do i go about writing the regex to extract only the numbers
20130207094852
Upvotes: 1
Views: 103
Reputation: 4376
See my comment on the question for context.
From a shell:
echo file-myfle_20130207_094852am.csv | tr -cd /0-9/
20130207094852
With Perl:
echo file-myfle_20130207_094852am.csv | perl -pe 's/\D//g'
20130207094852
Upvotes: 0
Reputation: 65049
Like this (this is pretty common among Regex tutorials)
\d+
Each group will be the numbers.
Upvotes: 5