我有這樣的字符串:需要解決一個正則表達式,它取代了太多
Text [City 1 || Location] text [Population]
|| Text [City 2 || Location] text [Population]
我需要正則表達式替換其中||只需在==中使用==。
所以我必須:
Text [City 1 == Location] text [Population]
|| Text [City 2 == Location] text [Population]
我寫這個正則表達式:
str = Regex.Replace(str, @"\[(.*?)\|\|(.*?)\]", "[$1==$2]");
但它取代所有||與==。
如何解決?
工程!謝謝!你能解釋這個正則表達式嗎? (?<= \ [[^ \ [\]] *)和(?= [^ \ [\]] * \])部分:-) – podeig 2012-08-13 10:50:23
在答案中添加。 – davidrac 2012-08-13 10:55:13