查看: 297|回复: 0
打印 上一主题 下一主题

[教程] powerpreg 004

[复制链接]

该用户从未签到

258

主题

1651

回帖

1万

积分

状元

Rank: 9Rank: 9Rank: 9

积分
19159

灌水大神章小蜜蜂章笑傲江湖章

跳转到指定楼层
1
发表于 2017-11-20 19:01:35 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Action Part: Extra Processing


The "extra processing" part of the Action panel is only visible when you've set the action type to "search and replace", rename files or folders, or "collect data". When you mark the "extra processing" checkbox, an extra set of controls for entering search terms appears.
"Extra processing" is simply a fancy name for an additional search-and-replace. This search-and-replace is not run on a file, but on each replacement text in a search and replace action, or on each text to be collected in a "collect data" action. It is most useful when the main action searches using regular expressions, and replaces or collects text using backreferences. The extra processing step is run after backreferences have already been substituted in the replacement text or text to be collected, giving you a chance to reformat them.
An example: when collecting data from URLs in the log files of a web server, you'll get back URL-encoded data. E.g. spaces appear as plus symbols, and plus symbols appear as %2B. With an extra processing step, you can search-and-replace the plus symbols back into spaces, etc. making the results a lot more readable.
Do not confuse extra processing with entering a list of search terms in the main part of a search-and-replace action. Each search-and-replace in the main part of the action is run on the entire file, or the entire section. The extra processing is only run on the replacement text, just before the main action makes a substitution. If the main action uses a list, the extra processing is applied to each replacement made by all items in that list.
Examples: Padding replacements, Rename Audio Files Using Meta Data, Rename files based on HTML title tags, Collect XML Data with entities replaced, Convert Windows to UNIX paths and Extract Google search terms from web logs
Named Capturing Groups Carry Over

When using regular expressions, named capturing groups carry over from the file sectioning and the main part of the action to extra processing. If the sectioning regex or main regex used a capturing group, you can use a backreference to that capturing group in the regular expression and/or the replacement text used for extra processing.