正则表达式

利用正则表达式,把文件中file="*"的内容全部替换

文件内容

<?xml version="1.0"?>
<!-- edited with XMLSpy v2006 U (http://www.altova.com) by Administrator (EMBRACE) -->
<!-- edited with XMLSPY v2004 rel. 4 U (http://www.xmlspy.com) by Fuzz (ORiON) -->
<AudioTagDatabase>
	<EFFECT ID="SM_ATK_01" FILE="sounds\char\swordman\sm_atk_01.wav" VOLUME_ADJUST="0" PRIORITY="0"/>
	<EFFECT ID="SM_ATK_02" FILE="sounds\char\swordman\sm_atk_02.wav"/>
	<EFFECT ID="SM_ATK_03" FILE="sounds\char\swordman\sm_atk_03.wav"/>
	<EFFECT ID="SM_DMG_01" FILE="sounds\char\swordman\sm_dmg_01.wav"/>
	<EFFECT ID="SM_DMG_02" FILE="sounds\char\swordman\sm_dmg_02.wav"/>
	<EFFECT ID="SM_DMG_03" FILE="sounds\char\swordman\sm_dmg_03.wav"/>
	<EFFECT ID="SM_GUE_ATK_01" FILE="sounds\char\swordman\sm_gue_01.wav"/>
	<EFFECT ID="SM_GUE_ATK_02" FILE="sounds\char\swordman\sm_gue_02.wav"/>
	<EFFECT ID="SM_BAL_READY" FILE="sounds\char\swordman\sm_bal1.wav"/>
	<EFFECT ID="SM_BAL_SHOT" FILE="sounds\char\swordman\sm_bal2.wav"/>
	<EFFECT ID="SM_TRIPLE1" FILE="sounds\char\swordman\sm_triple1.wav"/>
	<EFFECT ID="SM_TRIPLE2" FILE="sounds\char\swordman\sm_triple2.wav"/>
	<EFFECT ID="SM_TRIPLE3" FILE="sounds\char\swordman\sm_triple3.wav"/>
	<EFFECT ID="SM_HITBACK" FILE="sounds\char\swordman\sm_hitback.wav"/>

 java正则表达式\bFILE="[^"]*"

.NET正则表达式 @"\bFILE=""[^""]*"""

替换结果

<?xml version="1.0"?>
<!-- edited with XMLSpy v2006 U (http://www.altova.com) by Administrator (EMBRACE) -->
<!-- edited with XMLSPY v2004 rel. 4 U (http://www.xmlspy.com) by Fuzz (ORiON) -->
<AudioTagDatabase>
	<EFFECT ID="SM_ATK_01" FILE="" VOLUME_ADJUST="0" PRIORITY="0"/>
	<EFFECT ID="SM_ATK_02" FILE=""/>
	<EFFECT ID="SM_ATK_03" FILE=""/>
	<EFFECT ID="SM_DMG_01" FILE=""/>
	<EFFECT ID="SM_DMG_02" FILE=""/>
	<EFFECT ID="SM_DMG_03" FILE=""/>
	<EFFECT ID="SM_GUE_ATK_01" FILE=""/>
	<EFFECT ID="SM_GUE_ATK_02" FILE=""/>
	<EFFECT ID="SM_BAL_READY" FILE=""/>
	<EFFECT ID="SM_BAL_SHOT" FILE=""/>
	<EFFECT ID="SM_TRIPLE1" FILE=""/>
	<EFFECT ID="SM_TRIPLE2" FILE=""/>

你可能感兴趣的:(正则表达式)