作者:乃ah麟 | 来源:互联网 | 2023-09-11 11:34
Iwanttosplitasentenceintowordsandspecialcharacters.Iamusingtheregularexpressionbelo
I want to split a sentence into words and special characters. I am using the regular expression below:
我想把一个句子分成单词和特殊字符。我正在使用下面的正则表达式:
@"((\b[^\s]+\b)((?<=\.\w).)?)
But it returns only words and not special characters such as space-separated hyphens or colons.
但它只返回单词,而不返回特殊字符,如空格分隔的连字符或冒号。
Ideally, for the sentence:
理想情况下,对于句子:
"Right now!" she shouted, and hands fluttered in the air - amid a few cheers - for about two minutes.
“马上!”她喊道,双手在空中飘动 - 几声欢呼 - 大约两分钟。
I should get:
我应该得到:
Right
now
she
shouted
and
hands
fluttered
in
the
air
-
amid
a
few
cheers
-
for
about
two
minutes
3 个解决方案