[英]Regex select words longer than 4 characters but only one instance if duplicates
I am trying to format text in InDesign using GREP Style.我正在尝试使用 GREP 样式在 InDesign 中格式化文本。 The goal is to select words longer then 4 letters in a paragraph but if the word has been duplicated in a paragraph it should not select more then first instance of this word.目标是在段落中选择超过 4 个字母的单词,但如果该单词在段落中重复,则不应选择比该单词的第一个实例更多的单词。 This is sample text:这是示例文本:
"The Lord's right hand is lifted high; the Lord's right hand has done mighty things!" “主右手高举,主右手作大事!” The solution should give解决方案应该给出
i have done the first part我已经完成了第一部分
[[:word:]]{4,}
but don't have a clue how to deal with those duplicates.但不知道如何处理这些重复项。
Is order a requirement?订单有要求吗? If not, how about words longer than 4 characters not followed by that same word later in the text?如果不是,那么超过 4 个字符的单词后面没有跟同一个单词怎么办? See:看:
([[:word:]]{4,})(?!.*\1)
https://regex101.com/r/Ug4dLZ/1 https://regex101.com/r/Ug4dLZ/1
Result: lifted high Lord right hand done many things结果:举起高主右手做了很多事
To be more comprehensive, include word breaks (ie count "Person" and "Personhood" as 2 separate words):为了更全面,包括断词(即,将“Person”和“Personhood”计为 2 个单独的词):
([[:word:]]{4,})(?!.*\b\1\b)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.