Regex替换这些单词

Regex替换这些单词,regex,alternation,Regex,Alternation,我正在研究文件名以提供其他名称。 i、 我有一些重复的名字。 这是输入: image thisismyimage image image anotherimage 我正在寻找一种解决方案,为所有这些重复的名称提供替代名称。 image需要替换为imageofme、imageofher或nextimage 我期待这个结果 imageofme thisismyimage imageofher nextimage anotherimage 我使用

我正在研究文件名以提供其他名称。 i、 我有一些重复的名字。 这是输入:

 image  
 thisismyimage  
 image  
 image  
 anotherimage
我正在寻找一种解决方案,为所有这些重复的名称提供替代名称。
image
需要替换为
imageofme
imageofher
nextimage
我期待这个结果

 imageofme  
 thisismyimage  
 imageofher  
 nextimage  
 anotherimage
我使用的是简单的正则表达式,我试图用
[imageofme | imageofher | nextimage]
替换图像,但它给出了所有图像的名称,任何放在替换框中的内容都被整个
[imageofme | imageofher | nextimage]
替换。 是否有任何解决方案可以从中选择其他名称,或者获得唯一的名称来替换那些重复的名称(如图像编号或id)? 你知道如何在正则表达式中进行替换吗

如果您有Perl:

perl -pe '
    BEGIN { @alternative_names = qw(imageofme imageofher nextimage) }
    s/^image$/shift @alternative_names/e
' your_file

根据需要进行缩放。

有什么理由不手动缩放吗?如果你正在寻找一个编程解决方案,记事本++无论如何都不是正确的选择。不可能,它每周动态生成的名称太多了。任何编程解决方案都值得赞赏,@AlexMs:这不能仅用正则表达式来实现,您需要编写一些代码。你懂任何编程语言吗?@thg435是的,我懂。但我认为编程语言在这里不适用。