[英]Regex to strip all numbers and special characters but space and letters
Can someone help me out with the regular expression to strip a string like this -> 有人可以用正则表达式帮我解开像这样的字符串 - >
'226710': 'Kevin Werbach'
to obtain just --> Kevin Werbach 只获得 - > Kevin Werbach
My attempt --> 我的尝试 - >
instructors = re.sub(r'([^a-zA-Z\s]+?)', '', instructors)
which returned --> 返回 - >
KevinWerbach
without any space between. 没有任何空间。
This works: 这有效:
import re
text = "'226710': 'Kevin Werbach'"
print(re.sub (r'([^a-zA-Z ]+?)', '', text))
You can also change the space to \\s: 您还可以将空间更改为\\ s:
print(re.sub (r'([^a-zA-Z\s]+?)', '', text))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.