Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 正则表达式-从右开始,在相等处结束_C#_Regex - Fatal编程技术网

C# 正则表达式-从右开始,在相等处结束

C# 正则表达式-从右开始,在相等处结束,c#,regex,C#,Regex,我有以下uri结构: xxx.com/xxx/xxx?action=&anmp;someId=12334454 有人知道如何使用正则表达式返回uri/url末尾的数字吗 (\d+)$ 试试这个。只需抓取捕获并查看演示 试试这个。只需抓取捕获并查看演示 正则表达式从左到右匹配,但您可以使用$将表达式的结尾锚定到字符串的结尾: =(\d+)$ 这将查找=符号,然后捕获定位到字符串末尾的1+个数字 或者,您可以使用lookback为=断言,而不实际匹配它,以避免使用捕获组: (?<==)

我有以下uri结构:

xxx.com/xxx/xxx?action=&anmp;someId=12334454

有人知道如何使用正则表达式返回uri/url末尾的数字吗

(\d+)$
试试这个。只需抓取捕获并查看演示

试试这个。只需抓取捕获并查看演示


正则表达式从左到右匹配,但您可以使用
$
将表达式的结尾锚定到字符串的结尾:

=(\d+)$
这将查找
=
符号,然后捕获定位到字符串末尾的1+个数字


或者,您可以使用lookback为
=
断言,而不实际匹配它,以避免使用捕获组:

(?<==)\d+$

(?正则表达式从左到右匹配,但您可以使用
$
将表达式的结尾锚定到字符串的结尾:

=(\d+)$
这将查找
=
符号,然后捕获定位到字符串末尾的1+个数字


或者,您可以使用lookback为
=
断言,而不实际匹配它,以避免使用捕获组:

(?<==)\d+$

(?1-
&anmp;
在您的url中不正确

2-您不需要正则表达式来解析URI

string url = "http://xxxa.com/xxxa/xxxa?action=&someId=12334454";
var id = new Uri(url).ParseQueryString()["someId"];

1-
&anmp;
在您的url中不正确

2-您不需要正则表达式来解析URI

string url = "http://xxxa.com/xxxa/xxxa?action=&someId=12334454";
var id = new Uri(url).ParseQueryString()["someId"];