0
我有以下字符串:正則表達式給出不同的結果爲兩個類似箱子
消息1 [V.Variable1]消息2 [F.Field1]消息3
爲什麼它很好地工作在EX1和不在EX2?
var ex1 = Regex.Matches(message, @"\[F\.(?<name>.+)\]");
// the result `{[F.Field1]}` .. as expected
var ex2 = Regex.Matches(message, @"\[V\.(?<name>.+)\]");
// the result `{[V.Variable1] Message 2 [F.Field1]}` .. not as expected
當我試圖讓組name
的價值,它給了預期的結果在EX1是Field1
但它沒有返回值在EX2
任何想法?
定義「效果很好」和「不」。目前還不清楚你期望的結果是什麼。 – Oded
當我試圖獲得組名'的值,它給出了ex1的預期結果,它是'Field1',但它在ex2中不返回任何內容 – Homam
請編輯你的問題並用這些信息更新,而不是在評論,其他人可能忽略閱讀它。 – Oded