문제

The following line of code:

Match match = Regex.Match(json, ".*\"access_token\":\"(?<;token>;.*?)\".*", RegexOptions.IgnoreCase);

Is giving me the error:

ArgumentException: parsing ".*\"access_token\":\"(?<;token>;.?)\"." - Invalid group name: Group names must begin with a word character.

I took this code directly from: http://msdn.microsoft.com/en-us/library/dn546687.aspx

도움이 되었습니까?

해결책

You have a ; character between the ?< and the token

(?<;token>;
   ^ here

Remove this and it will eliminate the error.

다른 팁

In your RegEx you address your group naming it ";token" (between < and >). It's illegal. Use "token" instead.

Match match = Regex.Match(json, ".*\"access_token\":\"(?<token>;.*?)\".*", RegexOptions.IgnoreCase);

That regex is not correct. There are semi colons in it that needs to be removed.

Use this:

Match match = Regex.Match(json, ".*\"access_token\":\"(?<token>.*?)\".*", RegexOptions.IgnoreCase);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top