Util.ClearResults();
string tst = String.Join("", DateRange.Take(10).Select(d => d.DocHistory));
var matches = Regex.Matches (tst, "(?:[a-zA-Z'-]+[^a-zA-Z'-]+){0,2}assigned by(?:[^a-zA-Z'-]+[a-zA-Z'-]+){0,2}", RegexOptions.Multiline);
matches.Dump("Regex Matches");
foreach(var match in matches)
{
match.Dump("Ind Match");
}
ฉันมีรหัสนี้และดูเหมือนว่าจะทำงานได้อย่างถูกต้องในการจับ "ค่า" และไม่ได้แยกค่าเฉพาะออกจากนั้น:
ฉันมีสตริงดังต่อไปนี้: "คำขอปิดโดย Jack Arm เมื่อวันที่ 16/08/2018, Assignee #1 James Arye มอบหมายโดย Scotty Shep เมื่อวันที่ 16/08/2018, คำขอส่งโดย Mac Weaver เมื่อวันที่ 16/08/2018, สร้างคำขอแล้ว โดย Mac Weaver เมื่อวันที่ 16/08/2018"
ฉันกำลังพยายามแยกชื่อทางด้านซ้ายและด้านขวาของ "มอบหมายโดย" แต่ฉันได้รับ "James Arye มอบหมายโดย Scotty Shep"...มีวิธีที่จะแยก "คุณค่า" ออกหรือไม่ พบเป็น 3 ตัวแปรด้วย regex?
((?:[a-zA-Z'-]+[^a-zA-Z'-]+){0,2})assigned by((?:[^a-zA-Z'-]+[a-zA-Z'-]+){0,2})
- จากนั้นmatch.Groups[1].Value
และmatch.Groups[2].Value
จะเก็บผลลัพธ์ไว้ - person Wiktor Stribiżew   schedule 26.08.2018foreach (Match match in matches) { ... }
- person Wiktor Stribiżew   schedule 26.08.2018