Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.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 升华文本段中句点之前变量名的正则表达式_Regex_Sublimetext3_Sublimetext - Fatal编程技术网

Regex 升华文本段中句点之前变量名的正则表达式

Regex 升华文本段中句点之前变量名的正则表达式,regex,sublimetext3,sublimetext,Regex,Sublimetext3,Sublimetext,因此,我试图为Sublime Text 3编写一个片段,用于对象上调用的forEach语句 //what I have written at the point where the snippet is triggered myObject.forEa // what should appear after triggering the snippet Array.prototype.forEach.call(myObject, function(){ }) 这里的问题是在代码段的正则表达

因此,我试图为Sublime Text 3编写一个片段,用于对象上调用的
forEach
语句

//what I have written at the point where the snippet is triggered
myObject.forEa

// what should appear after triggering the snippet
Array.prototype.forEach.call(myObject, function(){

})
这里的问题是在代码段的正则表达式中捕获
myObject
,以便在编写代码段时可以重用它

到目前为止,我有一个正则表达式,它可以捕获任何适合作为我需要的
myObject
(\w\124;\)+\ b\.
。但是我需要捕捉光标前面的那个

您还可以使用一些环境变量,例如光标线条的内容、光标的水平位置


可以这样做吗?

只要我知道,您可以使用变量$TM\u CURRENT\u LINE来获取该行的内容,但唯一被替换的是制表符触发器(forEa),该行的其余部分仍然存在。我给你举个例子和另一个选择

示例(未按预期工作): 到

因此,您可以使用行内容,但
myObject.
仍位于行的开头

备选方案(不完全是您想要的,但工作正常): 我想你知道怎么做,但我认为最好用简单的方法:

<content><![CDATA[Array.prototype.forEach.call(${1:object}, function(){
    ${2:functionConent}
})]]></content>


更改后,焦点位于第一个字段(对象),因此您可以轻松编写它,然后可以使用tab移动到下一个字段(函数内容)。

您有此行为的文档吗?@MattDMo什么行为?在使用tab触发器时,是否可能替换所有行?没关系。我问的是不能被替换的
$TM\u CURRENT\u LINE
,但我刚刚做了一些实验,这似乎是真的,至少在最新的开发版本ST3中是这样。我认为真正解决OP问题的唯一方法是通过插件。我会看看我能做些什么…@MattDMo好的,不管怎样,我没有关于它的任何文档。
myObject.forEa
myObject.Array.prototype.forEach.call(myObject, function(){
    functionConent
})
<content><![CDATA[Array.prototype.forEach.call(${1:object}, function(){
    ${2:functionConent}
})]]></content>
forEa
Array.prototype.forEach.call(object, function(){
    functionConent
})