سؤال

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