I need a little help for finding regular expression that suits my need, what I want is that may the input be any string, the regular expression finds any and all integer values and returns them, say
string s1 = "This is some string"
string s2 = " this is 2 string"
string s3 = " this is 03 string"
string s4 = "4 this is the 4th string"
string s5 = "some random string: sakdflajdf;la 989230"
string s6 = "3494309 !@# 234234"
Now what I want is for the regular expression to return,
for s1 = return null (// nothing)
s2 = return 2
s3 = return 0 and 3 (// may separately as 0 and 3 or together as 03 doesn't matter)
s4 = return 4 and 4 (// it has 4 2 times right?)
s5 = 989230 (// may together as this or separately as 9 8 9 2 3 0 again is unimportant, but what's important is that it should return all integer values)
s6 = 3494309 and 234234 (// again may they be together as this or like this 3 4 9 4 3 0 9 and 2 3 4 2 3 4 that is unimportant, all that is imp is that it should return all integers)
I have tried [0-9]
, d
and ^.*[0-9]+.*$
, but none of them seemed to work. Can anyone please help?
ps : please see the updated question at Rename file using regular expression
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…