修改正则表达式组优先级(Modifying regex group priority)
我有以下正则表达式:
Regex regex = new Regex(@"(?<g1>a?)(?<g2>a?)(?<g3>b?)(?<g4>b?)");
和一个字符串
string str = @"ab";
将此正则表达式应用于我得到的字符串时
g1 -> "a", g2 -> "", g3 -> "b", g4 -> ""
是否可以修改此正则表达式来获取
? 那就是我希望g4的优先级高于g3。g1 -> "a", g2 -> "", g3 -> "", g4 -> "b"
I have the following Regex:
Regex regex = new Regex(@"(?<g1>a?)(?<g2>a?)(?<g3>b?)(?<g4>b?)");
and a string
string str = @"ab";
When applying this regex to the string I get
g1 -> "a", g2 -> "", g3 -> "b", g4 -> ""
Is it possible to modify this regex to get
? That is I want to have higher priority for g4 than for g3.g1 -> "a", g2 -> "", g3 -> "", g4 -> "b"
原文:https://stackoverflow.com/questions/2085553
最满意答案
不等式不作为HTTP参数概念存在。
>
可能只需要进行URL编码。HTTP参数是键=值对,因此
myval=>10
实际上可能意味着myval
=>10
。要发送
>10
,请尝试%3E10
>
URL编码为%3E
Inequalities don't exist as a HTTP parameter concept.
The
>
may just need to be URL encoded.HTTP Parameters are key=value pairs, so
myval=>10
might actually meanmyval
=>10
.To send though
>10
, try%3E10
as>
URL-encoded is%3E
相关问答
更多-
隔离y表明我们都是y>=ax+b形式的不等式。 这意味着我们可以绘制使用图的不等式,相等版本的函数以及函数在区间上获得的最大值。 using Plots f(x) = (2/5)x-6/5 g(x) = -x X = -10:10 the_max = max(f(X[end]), g(X[1])) plot(X, f, fill = (the_max, 0.5, :auto)) plot!(X, g, fill = (the_max, 0.5, :auto)) 这给了我们 如果第二个方程有不等式翻转的话 ...
-
测试列表中的不等式(Testing inequalities on lists)[2021-12-25]
根据您想要的结果,有几种方法可以做到这一点。 举个例子,你可以这样做: map [ ifelse-value (? > 0) [ ? ] [ 0 ] ] my-list map通过将给定的报告任务应用于给定列表的每个项目来创建新列表。 如果之前没有在NetLogo中使用过任务 , ? 表示任务的参数。 所以,在这种情况下做: map [ ifelse-value (? > 0) [ ? ] [ 0 ] ] [1 2 -1 -2] 基本上做了: (list ifelse-value (1 > 0) [ 1 ... -
==调用__eq__() 。 !=调用__ne__()如果它存在),否则相当于not == 。 除非1中的差异很重要。 == invokes __eq__(). != invokes __ne__() if it exists, otherwise is equivalent to not ==. Not unless the difference in 1 matters.
-
你正在混合两种不同类型的case语句: case var when 1 dosomething when 2..3 doSomethingElse end case when var == 1 doSomething when var < 12 doSomethingElse end You are mixing two different types of case statements: case var when 1 dosomething when 2..3 doSo ...
-
你的线性规划是一个问题,你的等式和不等式是局限性,你希望最小化(然后最大化)表达式y 。 平等,不平等和表达都是线性的,所以这使得它成为线性规划。 scipy软件包使用scipy.optimize.linprog函数可以完成这种线性编程。 这里是评论代码做你想做的。 请注意,所有不平等都稍微改变,以包含相等性,这是y的最大值或最小值所必需的。 要找到y的最大值,代码会找到-y的最小值,然后打印出该值的加法反比,因为linprog目标函数最小化。 最后, linprog的不等式限制必须“小于或等于”,所以我将 ...
-
您可以使用dis模块分析每个案例,以确切了解发生了什么。 例如: In [1]: import dis In [2]: def test(): ...: return 3 > 2 is True ...: In [3]: dis.dis(test) 2 0 LOAD_CONST 1 (3) 3 LOAD_CONST 2 (2) 6 DUP_TOP ...
-
目标C中的双重不等式(Double inequalities in Objective C)[2021-06-21]
Nope - Objective-C是C语言的超集,并且对于if语句使用与C相同的语法。 你必须把它分成两个不等式: if (x <= y && y <= z) 。 Nope - Objective-C is a superset of the C language, and uses the same syntax as C for if statements. You'll have to split that up into two inequalities: if (x <= y && y <= z ... -
[这个目标a = b ]的介绍是否合乎逻辑? 如果我理解你的问题,你想知道是否有可能有一个目标a = b ,调用intros contra ,并将其转换为目标H : a <> b |- False 。 这将是合理的,但在Coq的任意类型的a和b的基本构造逻辑中a不可推导的:它断言命题a = b支持双否定消除( ~ (~ a = b) -> a = b )。 Coq不支持这一点,因为它意味着以不同的逻辑形式主义工作。 如何通过destruct来使用不等式归纳? 正如yeputons所说, a <> b被定义为 ...
-
GET参数具有不等式(GET parameters with inequalities)[2022-01-23]
不等式不作为HTTP参数概念存在。 >可能只需要进行URL编码。 HTTP参数是键=值对,因此myval=>10实际上可能意味着myval = >10 。 要发送>10 ,请尝试%3E10 > URL编码为%3E Inequalities don't exist as a HTTP parameter concept. The > may just need to be URL encoded. HTTP Parameters are key=value pairs, so myval=>10 might ... -
渐近分析不等式(Asymptotic Analysis Inequalities)[2022-03-21]
准备工作 上面图像中红色标记部分上方的部分是Big-Θ符号的定义:“ f(n) Θ(g(n)) ”, f(n) = (n + a)^b, b > 0 (+) g(n) = n^b (++) 我们将重复这个不等式,以便在显示它如下所示时简化参考: f(n) is in Θ(g(n)) with f(n) and g(n) as in (+) and (++), respectively <=> c_1⋅n^b ≤ (n + a)^b ≤ c_2⋅ ...