fast way to remove lowercase substrings from string?

后端 未结 3 1098
予麋鹿
予麋鹿 2021-01-08 00:40

What\'s an efficient way in Python (plain or using numpy) to remove all lowercase substring from a string s?

s = \"FOObarFOOObBAR\"
remove_lowe         


        
3条回答
  •  孤街浪徒
    2021-01-08 01:04

    import re
    
    remove_lower = lambda text: re.sub('[a-z]', '', text)
    
    s = "FOObarFOOObBAR"
    s = remove_lower(s)
    
    print(s)
    

提交回复
热议问题