我正在使用一种对拼写有一些特殊规则的语言。当单词放在一起时,它们没有空格,但偶尔会使用'
or-
来-
区分一个单词的开头和结尾,在极少数情况下会发生混淆。
我当前显示的单词之间带有空格,例如:
The cat caught the mouse.
但是,我需要删除空格,例如:
Thecatcaughtthemouse.
但是,在删除这些空格之前,必须考虑有关放置'
和的规则:-
首先,如果一个单词的第一个字母(也跟在另一个单词后面)以元音开头(a
, a
, á
, à
, ǎ
, ā
, b
, c
, d
, e
, e
, é
, è
, ě
, ē
, , i
, i
, í
, ì
, ǐ
, ī
, o
, o
, ó
, ò
, ǒ
, ō
, u
, u
, ú
, ù
, ǔ
, ü
, ǘ
, ǜ
, ǚ
, ǖ
, or ū
),然后将空格替换为 a '
(单词之间),例如:
The cat ate the sandwich and the ice cream.
这变成:
Thecat'atethesandwichandthe'icecream.
这不适用于句子开头的单词。
接下来,如果一个单词的最后一个字母以“a”、“u”或“ü”开头(a
, a
, á
, à
, ǎ
, ā
, u
, u
, ú
, ù
, ǔ
, ü
, ǘ
, ǜ
, ǚ
, ǖ
, or ū
),句子中的下一个单词以“n”,然后将空格替换为-
(单词之间),例如:
The people from Australia needed a car to visit the plateau near the river.
这变成:
Thepeoplefrom'Australia-needed'acartovisittheplateau-neartheriver.
最后,如果一个单词的最后一个字母以“n”结尾,而句子中的下一个单词以“g”开头,则将空格替换为a -
(单词之间),例如:
The Australian grasshopper was lost in the overgrown grove.
这变成:
The'Australian-grasshopperwaslostinthe'overgrown-grove.
如何用'
and替换匹配这些模式的单词之间的空格-
?