且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从C#中的URL查询字符串中提取值?

更新时间:2023-02-26 09:15:43

token =(\d +)应该可以解决问题

也可以满足aplhas的需要要么执行以下操作:

To cater for aplhas as well you can do either:

token =([[a-zA-Z0-9 + / =] +)即可匹配您期望的字符。这将匹配令牌=,然后捕获与字符类匹配的所有以下字符,即az,AZ,0-9,+,/和=。

token=([a-zA-Z0-9+/=]+) to explicitly match on the characters you expect. This matches "token=" and then captures all following characters that match the character class, that is, a-z, A-Z, 0-9, +, / and =.

token =([[^&#] +)以匹配除您知道的字符以外的任何字符可以完成令牌。这匹配 token =,然后捕获所有字符,直到第一个& 或字符串的末尾

token=([^&#]+) to match any character except for the ones you know can finish the token. This matches "token=" and then captures all characters until the first &, # or the end of the string.