[英]How do I name a result group in a Regex? (.Net)
How do I name a result group in a Regex?如何在正则表达式中命名结果组? (.Net) (。网)
(?<NameOfGroup>[a-z]*)
Use the ?使用 ? syntax like in the sample above.语法类似于上面的示例。
(?<NAME>EXPRESSION) or (?'NAME'EXPRESSION)
(?<first>group)(?'second'group).
(?<name>.*)
Substitute with whatever you want to call your group.用您想称呼您的小组的任何内容代替。 whatever follow is the regular expression you expect to parse and match the result to the group.接下来是您希望解析并将结果与组匹配的正则表达式。
See my post this morning on example how to parse a file list for name and number index请参阅我今天早上关于如何解析文件列表以获取名称和数字索引的帖子
How to get files from 1 to n in a particular pattern? 如何以特定模式从 1 到 n 获取文件?
(?<name>subpattern)
Where < name > is the name of the group, and subpattern is the code For eg其中<name>是组名,subpattern是代码例如
(?<words>\w+)
same thing as \\w+
but named it "words"与\\w+
相同,但将其命名为“words”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.