目標:用由sup
標記包圍的連續星號替換連續星號。用數字替換字符
輸入
Hello, my name is Chris Happy*. My profile picture is a happy face.**
*: It's not my actual name, but a nickname.
**: Well, my "last name" is happy, so I think it's fitting.
輸出
Hello, my name is Chris Happy<sup>1</sup>. My profile picture is a happy face.<sup>2</sup>
<sup>1</sup>: It's not my actual name, but a nickname.
<sup>2</sup>: Well, my "last name" is happy, so I think it's fitting.
我怎麼能有效地做到這一點?
你想刪除什麼? –
不是「重複連續字符」而是「計數並替換_a特定字符_」?如果你想統計重複的連續字符,你會得到'快樂'中的'p'命中。 – msanford
我有點困惑,第一個匹配'my',''name'和'a',第二個匹配'my','name','is'和'happy', ?如果它只是匹配一個名字,你怎麼知道一個名字是什麼? – adeneo