Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.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 适用于visual studio 2013-2015的正则表达式查找和替换_Regex_Visual Studio_Replace - Fatal编程技术网

Regex 适用于visual studio 2013-2015的正则表达式查找和替换

Regex 适用于visual studio 2013-2015的正则表达式查找和替换,regex,visual-studio,replace,Regex,Visual Studio,Replace,我需要替换ff,但我必须保留内部内容,只使用类A替换tagA元素。任何没有类A的tagA都应该保持不变 <tagA class="a"> **random chars and line breaks occurrences** </tagA> <tagA class="a"> **random chars and line breaks occurrences** **random chars and line breaks occurrences** **

我需要替换ff,但我必须保留内部内容,只使用类A替换tagA元素。任何没有类A的tagA都应该保持不变

<tagA class="a">
**random chars and line breaks occurrences**
</tagA>

<tagA class="a">
**random chars and line breaks occurrences**
**random chars and line breaks occurrences**
**random chars and line breaks occurrences**
</tagA>

<tagA> //this guy should be left untouched since he is not class A
**random chars and line breaks occurrences**
**random chars and line breaks occurrences**
**random chars and line breaks occurrences**
</tagA>

**随机字符和换行符的出现**
**随机字符和换行符的出现**
**随机字符和换行符的出现**
**随机字符和换行符的出现**
//这家伙不应该被碰,因为他不是A级
**随机字符和换行符的出现**
**随机字符和换行符的出现**
**随机字符和换行符的出现**
应该由

<newTag>
**retain inner content**
</newTag>

<newTag>
**retain inner content**
**retain inner content**
**retain inner content**
</newTag>

<tagA>//untouched
**random chars and line breaks occurrences**
**random chars and line breaks occurrences**
**random chars and line breaks occurrences**
</tagA>

**内敛**
**内敛**
**内敛**
**内敛**
//未触及
**随机字符和换行符的出现**
**随机字符和换行符的出现**
**随机字符和换行符的出现**

我不使用VS,所以我不能对它做太多的了解,但您要做的是匹配以下模式:
(.*)

然后将其替换为:
\2


由于我没有VS,所以无法测试正则表达式,但想法应该很清楚。

搜索:


所以基本上你想用
newTag
替换
tagA class=“a”
?包括其相应的结束标记,但只有当开始标记有class=“a”时,你为什么要用
关闭
?哦,那是个错误…抱歉,如果这个答案解决了你的问题,我会替换它,请别忘了接受它。谢谢。最后一个问题,如果是:(A(B))(C)C的$number是多少?@MakotoLavan捕获组按照开始括号的顺序编号。这意味着
AB
是1,
B
是2,
C
是3。