English 中文(简体)
哪一个固定的表述操作人 是否与这种特性相符?
原标题:Which regular expression operator means Don t match this character?
  • 时间:2011-05-08 05:13:37
  •  标签:
  • regex

*, ?, + natures all meancompet this nature. 什么性质意味着没有达到这一目的? 实例将有所帮助。

最佳回答

您可以使用否定的特性类别来排除某些特性:例如[^abcde],除一个、b、c、d、e等特性外,还将与任何特性相对应。

除字面上注明所有特性外,您可使用shorthands内称职:[w](downcase)与任何“序号”(字母、编号和强调)相匹配,[W](uppercase)将与字体相匹配;同样,[d]>将与0-9位数相匹配,而[D]<><>>>>>>>>除0-9位数外,对等。

如果你使用PHP,你可以查阅.regex nature阶层文件

问题回答

说“高端对口”有两种方式:特性范围,零宽的负面 look头/l头。

前者:无与<代码>a,b,c0: [^a-c0]

后者:除<代码>foo和bar外,与任何三字母相匹配:

(?!foo/>,{3}

{3}(?<!foo/bar)

Also, a c或rection f或 you: *, ? and + do not actually match anything. They are repetition operat或s, and always follow a matching operat或. Thus, a+ means match one 或 m或e of a, [a-c0]+ means match one 或 m或e of a, b, c0, while [^a-c0]+ would match one 或 m或e of anything that wasn t a, b, c0.

[^] (in [ ] >) 是常规表述中的否定,而^<>>>>是“援引”的。

<> 代码>[^a-z]对从“a”到“z”的任何单一特性进行对比。

^[a-z]系指从“a”到“z”的起步。

https://en.wikipedia.org/wiki/Regular_expression”rel=“noreferer”>Reference<

^ used at the beginning of a character range, or negative lookahead/lookbehind assertions.

>>> re.match( [^f] ,  foo )
>>> re.match( [^f] ,  bar )
<_sre.SRE_Match object at 0x7f8b102ad6b0>
>>> re.match( (?!foo)... ,  foo )
>>> re.match( (?!foo)... ,  bar )
<_sre.SRE_Match object at 0x7f8b0fe70780>




相关问题
Uncommon regular expressions [closed]

Recently I discovered two amazing regular expression features: ?: and ?!. I was curious of other neat regex features. So maybe you would like to share some tricky regular expressions.

regex to trap img tag, both versions

I need to remove image tags from text, so both versions of the tag: <img src="" ... ></img> <img src="" ... />

C++, Boost regex, replace value function of matched value?

Specifically, I have an array of strings called val, and want to replace all instances of "%{n}%" in the input with val[n]. More generally, I want the replace value to be a function of the match ...

PowerShell -match operator and multiple groups

I have the following log entry that I am processing in PowerShell I m trying to extract all the activity names and durations using the -match operator but I am only getting one match group back. I m ...

Is it possible to negate a regular expression search?

I m building a lexical analysis engine in c#. For the most part it is done and works quite well. One of the features of my lexer is that it allows any user to input their own regular expressions. This ...

regex for four-digit numbers (or "default")

I need a regex for four-digit numbers separated by comma ("default" can also be a value). Examples: 6755 3452,8767,9865,8766,3454 7678,9876 1234,9867,6876,9865 default Note: "default" ...

热门标签