4
re.sub()
을 사용하여 문자열에서 색상 관리 코드 (IRC)를 제거하지만 매번 실패합니다.Python 정규식 : 오류 : 반복 할 항목이 없습니다.
re.sub('\x03(\d*)?,?(\d*)?', '', content)
오류 :
이File "/usr/lib/python2.7/re.py", line 151, in sub
return _compile(pattern, flags).sub(repl, string, count)
File "/usr/lib/python2.7/re.py", line 242, in _compile
raise error, v # invalid expression
error: nothing to repeat
내 정규식 잘못 아무것도 표시되지 않습니다를, 그래서 누군가가 내가 잘못 뭘하는지 설명 할 수 이것은 내가 사용하고 무엇입니까?
Google에서이 발견 (심지어 내 댓글이 있습니다) : http://stackoverflow.com/questions/5869650/python-regex-strange-behavior , 그리고 더 많은 것이 있습니다. – Kobi