我试图在接下来的场景中 将雷盖斯写得正确,但遇到了一些麻烦。下面是场景。
我的绳子看起来是这样的:
"办公时间(h) 介于8小时到18小时之间。"
从上面的字符串我需要 "8h"
和 18h"
。
到目前为止,我做了这个 ""[0-9]*"
。但是这让我有了 'h"
, 8h"
和 18h"
。
外面的专家有什么想法吗?
我试图在接下来的场景中 将雷盖斯写得正确,但遇到了一些麻烦。下面是场景。
我的绳子看起来是这样的:
"办公时间(h) 介于8小时到18小时之间。"
从上面的字符串我需要 "8h"
和 18h"
。
到目前为止,我做了这个 ""[0-9]*"
。但是这让我有了 'h"
, 8h"
和 18h"
。
外面的专家有什么想法吗?
将 [0-9]**[h]
替换为 [0-9]+h
表示它必须一次或多次出现。 括号
h
中没有任何用处, 因为它单独存在 。
您也可以使用 d+h
来增加可读性( d
匹配任何数字)。
用+(加号)替换 *,即:
[0-9]+[h]
在正方言中说:
* 表示匹配任何前一个标记数( 输入零) 。
+ 表示与前一个标记的任意数相匹配
另外,h周围的方括号是多余的,因为您只匹配一个字符。
表示 Regex 中的零重复或更多重复。 请指定重复的corret number。
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ <\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
d
表示一位数。
指一两次重复(
d
)。
表示词的开始或结束(因为任何字母或数字不应在模式之前或遵循模式)。
它不会找到 "h"
或 "123h"
或 18hertz"
。
您可以使用此正则 :
d+h
What is the use of default keyword in C#? Is it introduced in C# 3.0 ?
I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...
I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...
I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...
I have two EF entities. One has a property called HouseNumber. The other has two properties, one called StartHouseNumber and one called EndHouseNumber. I want to create a many to many association ...
How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...
Since I cannot order my dictionary, what is the best way of going about taking key value pairs and also maintaing an index?
Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...