0
나는 일생 일대의 것으로 보이고 작동시킬 수없는 코드를 만들었습니다.파이썬 : re.sub 패턴과 대체 와일드 카드
pattern = "\[([a-zA-Z0-9].*?)#([a-zA-Z0-9].*?)\]"
pattern_obj = re.compile(pattern, re.MULTILINE)
translation = pattern_obj.sub("<ol>\\1</ol>", translation)
는 내가 여기서 뭘하려고하는 텍스트를 변경할 수있다, 즉 :
[
# This is item number one in an ordered list. #
# And this is item number two in the same list. #
]
속으로 : 기본적으로
<ol>
#This is item number one in an ordered list. #
#And this is item number two in the same list. #
</ol>
,이 사이의 모든 텍스트를 식별하도록되어 [및] 텍스트의 어딘가에 #를 붙이고 [내부 문자]를 및 </ol>
으로 변경하고 모든 내부 텍스트를 동일하게 유지하십시오. 아무도 조언을 해줄 수 있습니까?
미리 감사드립니다.
감사합니다. 문제가 해결되었습니다. – user2421580