re.sub1 Regular expression operation (re.sub) re.sub(pattern, repl, string, count=0, flags=0) s = re.sub('[^a-z0-9]','',s) #[a-z0-9] --> matching any lower case letter a to z and digit of 0-9 ''' This will replace any special characters in 's' string with non-space blank characters. ''' -Example- s = 'abc#@%921' s = re.sub('[^a-z0-9]', '', s) s --> 'abc921' https://docs.python.org/3/library/re.html#re.sub re — Regular expression operations .. 2020. 8. 16. 이전 1 다음