TA的每日心情 | 无聊 2022-7-21 15:56 |
---|
签到天数: 216 天 [LV.7]常住居民III
状元
- 积分
- 16738
|
本帖最后由 wjl 于 2020-7-17 17:28 编辑
请问在EmEditor的正则表达式查找和替换中,能否实现数学计算功能,比如将<file name="(.*?)" guid=".*?"><analyse><perfect segments=".*?" words="(.*?)".*?<inContextExact segments=".*?" words="(.*?)".*?<exact segments=".*?" words="(.*?)".*?<locked segments=".*?" words="(.*?)".*?<crossFileRepeated segments=".*?" words="(.*?)".*?<repeated segments=".*?" words="(.*?)".*?<total segments=".*?" words="(.*?)".*?<new segments=".*?" words="(.*?)".*?<fuzzy min="50" max="74" segments=".*?" words="(.*?)".*?<fuzzy min="75" max="84" segments=".*?" words="(.*?)".*?<fuzzy min="85" max="94" segments=".*?" words="(.*?)".*?<fuzzy min="95" max="99" segments=".*?" words="(.*?)".*?</analyse></file>替换为\1,\6,\7,\2,\3,\4,$13,$12,$11,$10,\9,\8,\5\n,能否将\6,\7替换为它们的和
可以用以下示例内容进行测试:
<file name="Chap04.xml.sdlxliff" guid="294656b8-5378-4540-b897-a617d96003d0"><analyse><perfect segments="0" words="0" characters="0" placeables="0" tags="0" repairWords="0" fullRecallWords="0" partialRecallWords="0" edits="0" adaptiveWords="0" baselineWords="0" /><inContextExact segments="0" words="0" characters="0" placeables="0" tags="0" repairWords="0" fullRecallWords="0" partialRecallWords="0" edits="0" adaptiveWords="0" baselineWords="0" /><exact segments="83" words="517" characters="2536" placeables="55" tags="31" repairWords="0" fullRecallWords="0" partialRecallWords="0" edits="0" adaptiveWords="0" baselineWords="0" /><locked segments="0" words="0" characters="0" placeables="0" tags="0" repairWords="0" fullRecallWords="0" partialRecallWords="0" edits="0" adaptiveWords="0" baselineWords="0" /><crossFileRepeated segments="1008" words="81" characters="399" placeables="1138" tags="1138" repairWords="0" fullRecallWords="0" partialRecallWords="0" edits="0" adaptiveWords="0" baselineWords="0" /><repeated segments="97" words="471" characters="2453" placeables="205" tags="176" repairWords="0" fullRecallWords="0" partialRecallWords="0" edits="0" adaptiveWords="0" baselineWords="0" /><total segments="1453" words="3784" characters="18672" placeables="1855" tags="1760" repairWords="0" fullRecallWords="0" partialRecallWords="0" edits="0" adaptiveWords="0" baselineWords="0" /><new segments="208" words="2159" characters="10640" placeables="335" tags="316" repairWords="0" fullRecallWords="0" partialRecallWords="0" edits="0" adaptiveWords="0" baselineWords="0" /><newBaseline segments="0" words="0" characters="0" placeables="0" tags="0" repairWords="0" fullRecallWords="0" partialRecallWords="0" edits="0" adaptiveWords="0" baselineWords="0" /><newLearnings segments="0" words="0" characters="0" placeables="0" tags="0" repairWords="0" fullRecallWords="0" partialRecallWords="0" edits="0" adaptiveWords="0" baselineWords="0" /><fuzzy min="50" max="74" segments="0" words="0" characters="0" placeables="0" tags="0" repairWords="0" fullRecallWords="0" partialRecallWords="0" edits="0" adaptiveWords="0" baselineWords="0" /><fuzzy min="75" max="84" segments="0" words="0" characters="0" placeables="0" tags="0" repairWords="0" fullRecallWords="0" partialRecallWords="0" edits="0" adaptiveWords="0" baselineWords="0" /><fuzzy min="85" max="94" segments="26" words="247" characters="1190" placeables="51" tags="47" repairWords="0" fullRecallWords="0" partialRecallWords="0" edits="0" adaptiveWords="0" baselineWords="0" /><fuzzy min="95" max="99" segments="31" words="309" characters="1454" placeables="71" tags="52" repairWords="0" fullRecallWords="0" partialRecallWords="0" edits="0" adaptiveWords="0" baselineWords="0" /></analyse></file>
需要用支持10个以上分组的19.1以上的版本才行
Version 19.1 新增特性使用以下格式为超过 9 个的向后引用添加了正则表达式支持:\k<10>,\k<11>,\k<12>,…。如果用作替换表达式,则也可用以下格式:$10,$11,$12,…。
好像使用JavaScript语法进行替换,可以执行加减乘除。不过我不懂JavaScript语法
2020.7.17 我自己找到解决方案了,虽然不太完美,无法一次完成,执行完上述语句后,再接着执行 ^(.*?),(\d+?),(\d+?),替换为\J "\1," + (\2 + \3) + "," 即可
|
|