+ 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

13th Apr 2018, 8:34 AM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
6 Answers
+ 3
regular expressions are cool i guess https://code.sololearn.com/cIvM06xcutkb/?ref=app
13th Apr 2018, 11:40 AM
hinanawi
hinanawi - avatar
+ 14
🇳🇬Brains 's answer can be futher simplified as : alert(prompt().replace(/\D/g,""))
13th Apr 2018, 9:12 AM
Swapnil Srivastava
Swapnil Srivastava - avatar
+ 8
var str=prompt(); str=str.split(""); str.forEach(v=>{ if(v!=/^[a-zA-Z]+$/) str.splice(v,1); }); str=str.join("");
13th Apr 2018, 8:49 AM
᠌᠌Code X
᠌᠌Code X - avatar
+ 7
My try with Java;: 😄💚 https://code.sololearn.com/clSYJHPI4ojz/?ref=app
13th Apr 2018, 9:14 AM
Baraa AB
Baraa AB - avatar
+ 3
#Python print(''.join([i for i in input() if i.isdigit()])
13th Apr 2018, 2:36 PM
Louis
Louis - avatar