ReplaceHelper and FileReplacer's ReadMe.
ReplaceHelper and FileReplacer is Written by WANGXG on 2010.
They are Regex Replace tool, and the main functions is below.
Functions
① Regex's Matches, Show the MatchCollection Results in a tree.
tree structure:
+Match
| |--Group
| |--Capture[index, length]1
| |--Capture[index, length]1
|-----
| |--Group
| |--Capture[index, length]1
+Match
| |--Group
| |--Capture[index, length]1
② Replace By Group Index under conditions.
e.g.
input:[ ZIP:001002, TEL:009-0032-3232 ] AND [ ZIP:001002, TEL:009-0022-3232 ]
replace[ZIP:XXXXXX] to ZIP:002XXX, and replace[TEL:XX9-XXXX-XXXX] to [PHONE:XX3-XXXX-XXXX],
conditions: Only ZIP:XXX0XX AND NOT TEL:009-003X-XXXX will be replaced.
the replace systex is :
<item>
<pattern>
<![CDATA[
ZIP:([\d]{3})[\d]+,\s*(TEL):\d\d(\d)-[\d-]+
]]></pattern>
<replace group="1"><![CDATA[
002
]]></replace>
<replace group="2"><![CDATA[
PHONE
]]></replace>
<replace group="3"><![CDATA[
8
]]></replace>
<do><![CDATA[
ZIP:([\d]{3})0[\d]{2},\s*(TEL):\d\d(\d)-[\d-]+
]]></do>
<undo><![CDATA[
ZIP:[\d]+,\s*(TEL):009-002[\d-]+
]]></undo>
</item>
③ For Replace a text file and replace patterns by name, with the next XML format:
<?xml version="1.0" encoding="utf-8" ?>
<replaces>
<replace name="DeleteRemarksComment">
<item>
<pattern>
<![CDATA[\s*'''\s*\<remarks\>\s*\<\/remarks\>]]>
</pattern>
<replace group="0"><![CDATA[]]></replace>
</item>
</replace>
<replace name="AspControl2CustomControl">
<item>
<pattern>
(asp:)\w+
</pattern>
<replace group="1"> sct:Custom </replace>
</item>
</replace>
</replaces>
④ For different xmls:
<?xml version="1.0" encoding="utf-8" ?>
<replaces>
<replace file="SubReplace2.xml"/>
<replace file="SimplifyTextBox.xml"/>
<replace file="InsertResource.xml"/>
</replaces>
⑤ Add Systex with:
[$WORDS$]: use WORDS to replace
<$KEY$> : use dictionary[KEY] to replace.
{GROUPINDEX}: use Match.Group[GROUPINDEX] to replace.
没有评论:
发表评论