a?)(?
首页 \ 问答 \ 修改正则表达式组优先级(Modifying regex group priority)

修改正则表达式组优先级(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 -> ""

是否可以修改此正则表达式来获取

 g1 -> "a", g2 -> "", g3 -> "",  g4 -> "b"
? 那就是我希望g4的优先级高于g3。


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

 g1 -> "a", g2 -> "", g3 -> "",  g4 -> "b"
? That is I want to have higher priority for g4 than for g3.


原文:https://stackoverflow.com/questions/2085553
更新时间:2024-01-06 11:01

最满意答案

不等式不作为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 mean myval = >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)) 这给了我们 如果第二个方程有不等式翻转的话 ...
  • 根据您想要的结果,有几种方法可以做到这一点。 举个例子,你可以这样做: 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 ...
  • 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被定义为 ...
  • 不等式不作为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 ...
  • 准备工作 上面图像中红色标记部分上方的部分是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⋅ ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)