1. 程式人生 > >正則表示式匹配以某字串開始和結尾的字串

正則表示式匹配以某字串開始和結尾的字串

今天在整理MvvmCross(c# mvvm跨平臺框架)文件做epub電子書時,遇到到了文字顯示不太好,需要去掉指定開頭的字串。

然後寫了下面這個正則表示式

正則表示式

<a id="user.+</a>
可以匹配下面高亮這段文字

<h1 style="box-sizing: border-box; margin: 24px 0px 16px; line-height: 1.25; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(234, 236, 239); color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; orphans: 2; widows: 2;">

<a id="user-content-customizing-using-app-and-setup" class="anchor" href="https://github.com/MvvmCross/MvvmCross/blob/develop/docs/_documentation/fundamentals/Customizing-using-App-and-Setup.md#customizing-using-app-and-setup" aria-hidden="true" style="box-sizing: border-box; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; margin-left: -20px; line-height: 1;"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"/></svg></a>
Customizing using App and Setup</h1>

<p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; orphans: 2; widows: 2;">In each deployed MvvmCross application there are two key classes which control how your app starts:</p>