+ 4
[ASSIGNMENT] Remove All Characters from Input
Task: You need to create a program that takes user input in form of string containing numbers. Then, remove all the characters from that input. Input: solo56learn Output: 56 Input: Program2018 Output: 2018 You can use any language to perform this task. I already posted this challenge to Lesson Factory. https://code.sololearn.com/cfFiXFsr3lI2/?ref=app
6 Answers
+ 3
regular expressions are cool i guess
https://code.sololearn.com/cIvM06xcutkb/?ref=app
+ 14
đłđŹBrains 's answer can be futher simplified as :
alert(prompt().replace(/\D/g,""))
+ 8
var str=prompt();
str=str.split("");
str.forEach(v=>{
if(v!=/^[a-zA-Z]+$/)
str.splice(v,1);
});
str=str.join("");
+ 7
My try with Java;: đđ
https://code.sololearn.com/clSYJHPI4ojz/?ref=app
+ 3
#Python
print(''.join([i for i in input() if i.isdigit()])