我有一個字符串,我想用'|'將它拆分成數組,字符,但不 '\ |': var a = 'abc\&|\|cba';
var b = a.split(/([^\\])\|/);
結果: b = ["abc", "&", "|cba"]
預期輸出: b = ["abc\&", "\|cba"]
我基本上不能使用捕獲組在.split()函數正常。
我跟不上爲什麼這兩個表達式是不同的: ^(\d+)(?:\.(\d+))?(?:\.(\d+))?$
applied to 1.0.3
group 1 =>1
group 2 =>0
group 3 =>3
預計。但如果我嘗試概括它的任何系列\d\.那麼它不工作了: ^(\d+)(?:\.(\d+))+$
applied to 1.0.3
group 1 =>1
group 2
我正在嘗試學習Java正則表達式。我想將幾個捕獲組(即j(a(va)))與另一個字符串(即this is java. this is ava, this is va)匹配。我期待的輸出爲: I found the text "java" starting at index 8 and ending at index 12.
I found the text "ava" starting at i
我期望的C#這些行: var regex = new Regex("A(bC*)*");
var match = regex.Match("AbCCbbCbCCCCbbb");
var groups = match.Groups;
返回類似: ["AbCCbbCbCCCCbbb", "A", "bCC", "b", "bC", "bCCC", "b", "b", "b"]
而是它只返回