Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 用于标记的Vimscript正则表达式_Regex_Vim - Fatal编程技术网

Regex 用于标记的Vimscript正则表达式

Regex 用于标记的Vimscript正则表达式,regex,vim,Regex,Vim,我目前有以下vimscript函数通过光标获取当前HTML标记: fun s:GetCurrentTag() return matchstr(matchstr(getline('.'), \ '<\zs\(\w\|=\| \|''\|"\)*>\%'.col('.').'c'), '^\a*') endf 这段代码是别人写的,所以我不确定它到底在做什么。有人能简单解释一下吗。我还没有在网上找到任何好的vimscript regex文档 但是,最重要的是我想更改此函数,以便它可以检测

我目前有以下vimscript函数通过光标获取当前HTML标记:

fun s:GetCurrentTag()
return matchstr(matchstr(getline('.'),
\ '<\zs\(\w\|=\| \|''\|"\)*>\%'.col('.').'c'), '^\a*')
endf
这段代码是别人写的,所以我不确定它到底在做什么。有人能简单解释一下吗。我还没有在网上找到任何好的vimscript regex文档


但是,最重要的是我想更改此函数,以便它可以检测带有%和的标记。在它们中。

Vim的正则表达式记录在:help模式下。另请参见:帮助设计文档

由内而外,

getline“.”以字符串形式获取当前行。 matchstrstring,pat获取字符串中与pat模式匹配的部分。
matchstr(getline('.'), '<\zs\a*\ze\(\w\|[= ''"]\)*>\%' . col('.') . 'c')