简体   繁体   English

第二次出现之前的一切 -

[英]Everything before second occurrence of -

I am trying to use Power Rename (within Power Toys from Microsoft) to rename a large number of files.我正在尝试使用 Power Rename(在 Microsoft 的 Power Toys 中)重命名大量文件。 I need to remove everything after the second occurrence of a - and keep the file extension of.pdf at the end.我需要在第二次出现 - 之后删除所有内容,并在最后保留文件扩展名.pdf。 In other words, I want to only keep what is before the second - and the file extension of.pdf at the end换句话说,我只想保留第二个之前的内容 - 以及最后的文件扩展名.pdf

Here are three examples:以下是三个例子:

Tab 3-3-zo.pdf选项卡 3-3-zo.pdf

Should be Tab 3-3.pdf应该是 Tab 3-3.pdf

Tab 2-3-jk2.pdf选项卡 2-3-jk2.pdf

Should be: Tab 2-3.pdf应该是:选项卡 2-3.pdf

Tab 3-3-Yuwk-3-kls.pdf选项卡 3-3-Yuwk-3-kls.pdf

Should be: Tab 3-3.pdf应该是:Tab 3-3.pdf

I am having significant trouble trying to figure this out.我在试图弄清楚这一点时遇到了很大的麻烦。 Any help appreciated:)任何帮助表示赞赏:)

You can use您可以使用

/^([^-\n]*-[^=\n]*)-.*$/

Demo演示

If you want to capture the extension:如果要捕获扩展名:

/^([^-\n]*-[^=\n]*)-.*?(\.\w+)$/

Demo 2演示 2

If you only want to match .pdf files (including .PDF ):如果只想匹配.pdf文件(包括.PDF ):

/^([^-\n]*-[^=\n]*)-.*?(?i)(\.pdf)$/

Demo 3演示 3

It is super unclear in your question, but you may mean this:您的问题非常不清楚,但您的意思可能是这样的:

/^([^-\n]*-).*?(?i)(\.pdf)$/

Demo 4演示 4

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用正则表达式在倒数第二次出现之前获取所有内容? - How to get everything before the second-to-last occurrence with a regex? 如何将所有内容匹配到字符的第二次出现? - How to match everything up to the second occurrence of a character? 在第二次出现某个字符串后排除所有内容 - Exclude everything after the second occurrence of a certain string 在 hive 上第 n 次出现分隔符之前获取所有内容 - Get everything before nth occurrence of delimiter on hive R,第 n 次出现之前所有内容的正则表达式 - R, regular expression for everything before nth occurrence 正则表达式 - 在第二次出现之前返回所有内容 - regex - return all before the second occurrence 替换字符正则表达式之前的第二次出现 - replace second occurrence before character regular expression 寻找一个正则表达式,它将使我在第二次出现“ /”之后的所有事情 - Looking for a Regular Expression that will allow me to everything after the second occurrence of “/” 即使破折号出现在域中,也会在第二次出现后删除所有内容 - remove everything after second occurrence even if dash occur in domain 查找第三个出现的特殊字符,并将所有在此之前的字符删除 - Find third occurrence of a special character and drop everything before that in R
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM