+ 3
How to print only The Numbers from a alphanumeric String?
Eg. Input sdg45mkf567kdd3j(Take Input As A String) Output 45 567 3
8 Answers
+ 4
Is this what you mean?
https://code.sololearn.com/c7CsfGVC0JPF/?ref=app
+ 5
Use regular expressions...
As methods names depends on wich language implementation, example in Javascript:
var inp = 'sdg45mkf567kdd3j';
var out = inp.replace(/[^\d]+/g,' ');
console.log('>'+out+'<');
... or in two times, to strip eventuals boundings spaces:
var out = inp.replace(/^[^\d]+|[^\d]+$/g,'').replace(/[^\d]+/g,' ');
console.log('>'+out+'<');
+ 3
If I know how, I would recommend it like @visph example, using RegEx, less code to write, and no need to reinvent the wheel :)
+ 3
@Ipang: so, I suppose there's no built-in regex parser in C++? But I guess there's some in Java, doesn't it?
+ 3
@visph, I really don't know how to use regex in C++, as a matter of fact I'm still having difficulties understanding the meaning/usage of regex string filter, maybe I should make this a homework :)
+ 2
No, I can't: I never have used regular expression with those languages... I can do it in Python if you want ^^
+ 1
@visph Can You Send Me The Codes In C,c++ or Java??
I am not familiar with JavaScript..
So plzz
0
yeah!!
Thank You Very Much š