大家好我正在通過一些舊的代碼,並跑過一個reg-ex,我不知道它做了什麼,任何人都可以闡明它。正則表達式 - 文檔
<(.|\n)*?>|{(.|\n)*?}
它在替換string.replace語句。
大家好我正在通過一些舊的代碼,並跑過一個reg-ex,我不知道它做了什麼,任何人都可以闡明它。正則表達式 - 文檔
<(.|\n)*?>|{(.|\n)*?}
它在替換string.replace語句。
根據使用RegexBuddy這是它的劑量:
Match either the regular expression below (attempting the next alternative only if this one fails) «<(.|\n)*?>»
Match the character 「<」 literally «<»
Match the regular expression below and capture its match into backreference number 1 «(.|\n)*?»
Between zero and unlimited times, as few times as possible, expanding as needed (lazy) «*?»
Note: You repeated the capturing group itself. The group will capture only the last iteration. Put a capturing group around the repeated group to capture all iterations. «*?»
Match either the regular expression below (attempting the next alternative only if this one fails) «.»
Match any single character that is not a line break character «.»
Or match regular expression number 2 below (the entire group fails if this one fails to match) «\n»
Match a line feed character «\n»
Match the character 「>」 literally «>»
Or match regular expression number 2 below (the entire match attempt fails if this one fails to match) «{(.|\n)*?}»
Match the character 「{」 literally «{»
Match the regular expression below and capture its match into backreference number 2 «(.|\n)*?»
Between zero and unlimited times, as few times as possible, expanding as needed (lazy) «*?»
Note: You repeated the capturing group itself. The group will capture only the last iteration. Put a capturing group around the repeated group to capture all iterations. «*?»
Match either the regular expression below (attempting the next alternative only if this one fails) «.»
Match any single character that is not a line break character «.»
Or match regular expression number 2 below (the entire group fails if this one fails to match) «\n»
Match a line feed character «\n»
Match the character 「}」 literally «}»
的匹配爲:
<>
<...>
{}
{...}
當......是任何文字
你一定要點擊那個[鏈接](http://bit.ly/1fV9eHg) – MaxSC
@MaxS - 真搞笑!我喜歡有人有這樣一個優勢複雜,他們必須抓住每一個機會,只是展示它,如果你不想回答這個問題,或者甚至認爲這是愚蠢的問題,你應該忽略它。 – Ksliman
對不起,已經冒犯了你。目的不是炫耀或什麼。即使它是某種(不好的,我承認)的笑話,所提供的鏈接確實會讓你成爲一個非常好的工具來幫助你用正則表達式。我的評論是一種說明它在[SO幫助頁面](http://stackoverflow.com/help/how-to-ask)的搜索和研究部分寫的內容的方式。但是,再次,對不起。 – MaxSC