什么是“非法原住民"?在awk中? [英] What is an "illegal primary" in awk?
问题描述
Awk给我以下错误:
Awk gives me the following error:
awk: illegal primary in regular expression (?<=\>)(.*?)(?=\<) at <=\>)(.*?)(?=\<)
source line number 10 source file transpile.awk
context is
match($0, >>> /(?<=\>)(.*?)(?=\<)/) <<<
但是什么是"emem"?
But what is an "illegal primary"?
推荐答案
用awk的话来说,"primary"是正则表达式的基本单位.
A "primary", in awk parlance, is the basic unit of a regex.
正则表达式由(1个或多个)分支的替代组成.每个分支都由一个(0个或多个)主键组成.
A regex consists of an alternative of (1 or more) branches. Each branch consists of a concatenation of (0 or more) primaries.
主要字符可以是普通字符(例如a
),转义的特殊字符(例如\*
),字符类([...]
),点(.
)或定位符(^
或$
)或带括号的子表达式((...)
).其中大多数也可以有一个量词(?
,+
,*
).
A primary is either a normal character (e.g. a
), or an escaped special character (e.g. \*
), or a character class ([...]
), or a dot (.
), or an anchor (^
or $
), or a parenthesized subexpression ((...)
). Most of these can have a quantifier (?
, +
, *
), too.
正则表达式的问题是(?<=\>)
首先解析为(
,这将启动一个子组.然后,下一项需要是主要的. ?
不是有效的主数据库,因此会出现错误.
The problem with your regex is that (?<=\>)
parses as (
first, which starts a subgroup. The next item then needs to be a primary. ?
is not a valid primary, hence you get an error.
Awk不支持先行或先行.
Awk does not support look-ahead or look-behind.
这篇关于什么是“非法原住民"?在awk中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!