我有一个数据,它是用管道分隔的,例如。
1|2|3|4|5|6|7|8|9|10|
我只需要复制和粘贴(到新工作表(管道 6 - 9 之间的内容 我有 10,000 行这样的行
我们该怎么做呢?我们如何为相同的宏编写宏?还有其他解决方案吗?
将整个文本复制到新的缓冲区中,然后编辑文本以删除不需要的部分。可以使用正则表达式替换所有^(?:[^|rn]*|){5}([^|rn]*)|.*$
来做到这一点1
.
解释
^ - start of line
(?: - start of a non-capturing group
[^|rn]* - 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
([^|rn]*) - 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
最后的$
不是严格需要的。但是,当考虑开头^
时,它用于记录正则表达式查看整行。