let store = {
data: Immutable.Map({ activeKey: 1 })
};
这会将输出设为formatter_fn = lambda sentence: re.sub(r'([^\s\w\.])+', '', sentence).lower()
formatter_fn('\r\ndirected; by Nolan.')
,但我希望它为\r\ndirected by nolan.
在这种情况下如何删除directed by nolan.
?
谢谢!
答案 0 :(得分:1)
试试这个
re.sub(r'[^ \w\.]', '', sentence).lower()
\s
相当于集合[ \t\n\r\f]
,但您只需要空格(我猜)。
所以当你使用
时re.sub(r'[^\s\w\.]', '', sentence).lower()
除了space
,\t
,\n
,\r
,\f
)< - {{1}的一部分外,它将匹配任何内容},\s
和\w
。因此无法在字符串中匹配.
和\r
。
如果您想在集合中加入\n
,则可以使用
\t