Я хочу написать регулярное выражение, которое будет захватывать названия книг /фильмов.(?: # Start of group:
\b # Match start of a word
(?: # Start of inner group:
[A-Z]*
[A-Z][a-z]* # Either match an uppercase word
| # or
(?:a[nts]|the|by|for|i[nt]| # one of these "special" words
o[fnr]|to|up|and|but|nor)
) # End of inner group
\b # Match end of word
\s* # Match one or more whitespace characters
)+ # Match one or more of the above.
< /code>
Мой ввод выглядит следующим образом: < /p>
I watched the movie The Girl With the Dragon Tattoo but it wasn't very good.
< /code>
Это соответствует: < /p>
I
the
The Girl With the Dragon Tattoo but it
< /code>
Я понимаю, что это сложная проблема, и хотя я бы хотел, чтобы он только вернулся: < /p>
The Girl With the Dragon Tattoo
< /code>
Я был бы в порядке с: < /p>
I
The Girl With the Dragon Tattoo
< /code>
Как я могу изменить свою репутацию для достижения этого? < /p>
Подробнее здесь: https://stackoverflow.com/questions/359 ... rab-titles