要求是:
"link: <http://www.google.com|www.google.com> link1: <http://www.jira.com|www.jira.com>\n\n\n"
需要顯示為:
"link: www.google.com link1: www.jira.com"
對此的任何解決方案。
uj5u.com熱心網友回復:
你可以試試正則運算式:
Regex.Replace(
input: "link: <http://www.google.com|www.google.com> link1: <http://www.jira.com|www.jira.com>\n\n\n",
pattern: @"<[^|]*\|([^>]*)>",
replacement: "$1")
輸出:
link: www.google.com link1: www.jira.com
作業示例:https ://dotnetfiddle.net/fn99jz
正則運算式分解:
< // Match a literal '<'.
[^|]* // Match all characters until reaching a '|'.
\| // Match a literal '|' (needs escaping).
( // Start capturing all characters that
// match the following expression.
[^>]* // Match all characters until reaching a '>'.
) // Stop capturing and store the previous match
// in the reference '$1'.
> // Match a literal '>'.
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/465589.html
