Я думаю, что сообщение снова открывается после небольшой перезаписи вопроса.
Это перемещено из комментариев в область ответа.
Некоторое время назад я увидел эту проблему стиля на вопрос о не дублирующих символах
, который объединил всю строку. Я просто перевел его в рамки слов.
@ Michael J Mulligan сделал для этого тестовый пример (см. Комментарии).
Ссылки:
'Рабочая Regex тест (regex101.com/r/bA2wB0/1) и пример рабочего PHP (ideone.com/7ID8Ct)'
# For NO duplicate letters anywhere within word characters
# -----------------------------------------------------------
# \b(?!\w*(\w)\w*\1)\w+
\b # Word boundry
# Only word chars now
(?! # Lookahead assertion (like a true/false conditional)
# It doesn't matter if the assertion is negative or positive.
# In this section, the engine is forced to match if it can,
# it has no choice, it can't backtrack its way out of here.
\w*
(\w) # (1), Pick a word char, any word char
\w*
\1 # Now it is here again
# Ok, the expression matched, time to check if the assertion is correct.
) # End assertion
\w+ # Its here now, looks like the assertion let us through
# The assert is that no duplicate word chars ahead,
# so free to match word chars 'en masse'
# For ONLY duplicate letters anywhere within word characters
# just do the inverse. In this case, the inverse is changing
# the lookahead assertion to positive (want duplicates).
# -----------------------------------------------------------
# \b(?=\w*(\w)\w*\1)\w+
Это хорошо. Удачи, выясняя это. У вас возникли вопросы? –
Звучит как вопрос о домашнем задании. С неправильным подходом, взятым с места в карьер. –
regex определенно неправильно, что бы это ни было – developerwjk