我有一个数据是管道分开前。
1|2|3|4|5|6|7|8|9|10| 我必须复制和粘贴(到新的纸张),只有在管道6-9之间,我有10,000行像这样
我们怎么能这么做?我们如何为相同的宏编写宏?还有别的解决办法吗?
发布于 2017-07-20 09:42:58
将整个文本复制到一个新的缓冲区中,然后编辑文本以删除不需要的部分。可以用正则表达式替换--所有的^(?:[^|\r\n]*\|){5}([^|\r\n]*)\|.*$都用\1替换。
解释
^ - start of line
(?: - start of a non-capturing group
[^|\r\n]* - zero or more characters that are not a | or newlines or carriage returns
\| - a |
){5} - exactly 5 occurences of the previous group
-- the efect of the above is to match the unwanted leading characters
([^|\r\n]*) - a group containing the characters to keep
-- the wanted part of the line is saved in capture group 1
\|.*$ - a | then everything else to the end of the line
-- matches the unwanted right-hand part of the line严格来说,不需要最终的$。但是,当考虑到开头的^时,它可以记录正则表达式查看整行。
https://stackoverflow.com/questions/45206975
复制相似问题