REGEX选择超过4个字符的单词,但仅一个实例,如果重复

发布于 2025-02-01 02:47:06 字数 253 浏览 4 评论 0原文

我正在尝试使用GREP样式在Indesign中格式化文本。 目的是在段落中选择比4个字母更长的单词,但是如果在段落中重复该单词,则不应选择该单词的第一例实例。 这是示例文字:

“主的右手被抬高;主的右手做了强大的事情!” 解决方案应该让

  • 右手抬起

我在第一部分所做的

[[:word:]]{4,}

强大的事情,但不知道如何处理这些重复项。

I am trying to format text in InDesign using GREP Style.
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.
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

  • Lord right hand lifted high done mighty things

i have done the first part

[[:word:]]{4,}

but don't have a clue how to deal with those duplicates.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷途知返 2025-02-08 02:47:06

是订单要求吗?如果不是,那么稍后文本中的单词比4个字符不跟随同一单词的单词呢?请参阅:

([[:word:]]{4,})(?!.*\1)

https://regex101.com/r/r/ug4dlz/1

结果右手做了很多事情

要更全面,包括单词中断(即“人”和“人格”作为两个单独的单词):

([[:word:]]{4,})(?!.*\b\1\b)

Is order a requirement? If not, how about words longer than 4 characters not followed by that same word later in the text? See:

([[:word:]]{4,})(?!.*\1)

https://regex101.com/r/Ug4dLZ/1

Result: lifted high Lord right hand done many things

To be more comprehensive, include word breaks (i.e. count "Person" and "Personhood" as 2 separate words):

([[:word:]]{4,})(?!.*\b\1\b)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文