如何在 C# 中使用正则表达式拆分此行
本文关键字:正则表达式 拆分 | 更新日期: 2023-09-27 18:31:13
Input
-n. 1 geographical map or plan, esp. for navigation. 2 sheet of information in the form of a table, graph, or diagram. 3 (usu. in pl.) colloq. listing of the currently best-selling pop records. -v. make a chart of, map. [Latin charta: related to *card1]
我需要像这样拆分它
-n.
1 geographical map or plan, esp. for navigation.
2 sheet of information in the form of a table, graph, or diagram.
3 (usu. in pl.) colloq. listing of the currently best-selling pop records.
-v.
make a chart of, map. [Latin charta: related to *card1]
我的表情在这里 ((—'w'.)|('d's))(([^'d—])*)
但这在card1]
如何解决这个问题?
如何否定digit followed with space
?
利用前瞻:
((-'w'.)|('d's))(([^'d-]|('d(?!'s))|(-(?!'w'.)))*)
您需要任意数量的非数字或非短划线 ([^'d-]
),但您还希望允许不后跟空格('d(?!'s))
的数字和不后跟字符和句点的连字符(-(?!'w'.))
。
你应该对输入字符串执行 Regex.Escape 操作。