无法在Visual Studio 2012 RC中使用表达式组使用正则表达式查找和替换 [英] Unable to use expression groups in Visual Studio 2012 RC find and replace using regular expressions

查看:112
本文介绍了无法在Visual Studio 2012 RC中使用表达式组使用正则表达式查找和替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已阅读
在Visual中使用正则表达式Studio
并将我的正则表达式更改为新语法。

Have read Using Regular Expressions in Visual Studio and changed my regular expression to the new syntax.

但是,我无法找到并替换使用表达式组。

However, I'm unable to get find and replace working with expression groups.

示例:

<script type="text/javascript" src="@Url.Content("~/Scripts/jqPlot/plugins/jqplot.barRenderer.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/jqPlot/plugins/jqplot.pieRenderer.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/jqPlot/plugins/jqplot.canvasAxisTickRenderer.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/jqPlot/plugins/jqplot.canvasTextRenderer.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/jqPlot/plugins/jqplot.categoryAxisRenderer.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/jqPlot/plugins/jqplot.pointLabels.js")"></script>

这里是我的查找模式:

<script (type="text/javascript") (src="[\@\(\)~a-zA-Z0-9/."]*")>

而且,我想要这种替换模式:

And, I want this replacement pattern:

<script \2 \1>

我知道这是微不足道的,但这只是我无法做到的一个例子。

I understand that this is trivial but it's just one example of what I'm unable to do.

我选择了"使用正则表达式"对于查找和替换文本搜索选项(这本身就令人困惑,因为它表明断开连接)。

I've selected "Use Regular Expression" for both Find and Replace text search options (which is confusing in itself as it suggests a disconnect).

Visual Studio方便地高亮显示示例行,表明我的查找模式至少是正确的。但是,替换结果是"< script \2 \1>"。表达式组(即type =" text / javascript")没有被替换。

Visual Studio is conveniently hightlighting the example lines suggesting that my find pattern is at least correct. However, the replacement result is "<script \2 \1>". The expression groups (i.e. type="text/javascript") aren't being replaced.

我做错了什么?

推荐答案

你可能现在已经知道了,但是替换字段中的语法标记表达式已更改。  而不是\ 1,\\\,你使用
You likely figured it out by now, but the syntax in the replace field for tagged expressions has changed.  Instead of \1, \2, you use


1,


2。


这篇关于无法在Visual Studio 2012 RC中使用表达式组使用正则表达式查找和替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆