无效的组名称:组名称必须以一个单词字符开头 [英] Invalid group name: Group names must begin with a word character

查看:1416
本文介绍了无效的组名称:组名称必须以一个单词字符开头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我,当我使用Regex类的正则表达式收到以下异常:(?'命名a'asdf)

I received the following exception when I was using the Regex class with the regular expression: (?'named a'asdf)

System.ArgumentException: parsing \"(?'named a'asdf)\" - Invalid group name: Group names must begin with a word character.

什么是我的正则表达式的问题?

What is the problem with my regular expression?

推荐答案

问题是在捕获的名称空间。拆下空间和正常工作

The problem is the space in the name of the capture. Remove the space and it works fine.

从MSDN文档:
用于名称不得包含任何标点符号,并且不能以数字开头的字符串。您可以使用单引号代替尖括号(?'名')。例如,

From the MSDN documentation: "The string used for name must not contain any punctuation and cannot begin with a number. You can use single quotes instead of angle brackets; for example, (?'name')."

这不,如果你使用的尖括号<关系;>或单引号''来表示一个组名。

It does not matter if you use angle brackets <> or single quotes '' to indicate a group name.

这篇关于无效的组名称:组名称必须以一个单词字符开头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆