#Regular Expression
目前在修Programming for everybody 的第三个系列课程,也是第一次涉及到Python的库,感觉单靠记忆略有难度,故于此留下点滴记录。
特殊字符:
‘^’ start with
‘\S’ non-blank character
‘+’ at least one
'’ zero or more than one
‘[^ character]’ everything but this character
‘’ make the special characters such as ^,,$, etc the real character of what it should be
‘[1-9.]’ all numbers of this string(return a list of string of number such as [‘1’,‘2’]) (note dot here means real number)
‘[AEIOU]’ all upper vowel charact
·re.method()
re.search():useage: re.search(’…’,x) // success return true ;failed return false
re.findall(): useage: re.findall('^From: (\s+@\s+)',x) //translation: match string start with 'From:', and extract string as '\s+@\s+''.
tips:parentheses here just show which part to extract