+ 1
How to remove alphabets characters from the input String?
Input : @1456hello13#%+?!/:'*" Output : @145613#%+?!/:'*"
5 Respostas
+ 2
result = "".join(list(filter(lambda x: not x.isalpha(), input())))
print(result)
+ 1
Javascript code is wrong
+ 1
A bit late, but anyway my try with a pure list comprehension:
inp = "@1456hello13#%+?!/:'*"
#Output : @145613#%+?!/:'*"
# if you need to get the result as data
res = ''.join([i for i in inp if not i.isalpha()])
print(res)
# if you only need to print result
print(''.join([i for i in inp if not i.isalpha()]))
0
In javascript :
const string = "@1456hello13#%+?!:'*";
const withoutChar = string.replace(/[a-zA-Z]/g, '');
console.log(withoutChar);
In python is almost same :
import re
re.sub('[a-zA-Z]', '', string);
print(string);
0
Black Cap🇮🇳 Hey, lol. I forgot to include that tiny 'g' after /[a-zA-Z]/. Please test it again :))