在下面的文件示例(a.glo)中,需要将四个加粗的 "é" 替换为 "e"。 我使用的正则表达式可能有些丑陋:
(\\glossaryentry\{(\w|\s|\.)*)(é|è|ê|ë|É|È|Ê|Ë|ē)+
它可以与像www.regex101.com/和notepad++这样的在线测试器一起使用!
但是,当我在Windows命令行中输入时,没有任何变化:
perl -pi -i.bak -e "s/(\\glossaryentry\{(\w|\s|\.)*)(é|è|ê|ë|É|È|Ê|Ë|ē)+/$1e/g" a.glo
(值得一提的是,在我的系统上,Perl的版本是5.20.2)
a.glo:
\glossaryentry{AHRF@ {\memgloterm{AHRF}}{\memglodesc{法国大革命历史年鉴}} {\memgloref{}}|memjustarg}{1}
\glossaryentry{Ass. plén.@ {\memgloterm{Ass. plén.}}{\memglodesc{全会}} {\memgloref{}}|memjustarg}{1}
\glossaryentry{Ch. réun.@ {\memgloterm{Ch. réun.}}{\memglodesc{联席会议}} {\memgloref{}}|memjustarg}{1}
\glossaryentry{chron.@ {\memgloterm{chron.}}{\memglodesc{编年史}} {\memgloref{}}|memjustarg}{1}
\glossaryentry{Circ. min.@ {\memgloterm{Circ. min.}}{\memglodesc{部长通告}} {\memgloref{}}|memjustarg}{1}
\glossaryentry{éd.@ {\memgloterm{éd.}}{\memglodesc{编辑, 由...编辑}} {\memgloref{}}|memjustarg}{1}
\glossaryentry{Int J Semiot Law@ {\memgloterm{Int J Semiot Law}}{\memglodesc{国际法律符号学杂志}} {\memgloref{}}|memjustarg}{1}
\glossaryentry{Oxford J Legal Studies@ {\memgloterm{Oxford J Legal Studies}}{\memglodesc{牛津法律研究杂志}} {\memgloref{}}|memjustarg}{1}
\glossaryentry{préc.@ {\memgloterm{préc.}}{\memglodesc{见上文}} {\memgloref{}}|memjustarg}{1}
\glossaryentry{Rev. adm.@ {\memgloterm{Rev. adm.}}{\memglodesc{行政审查杂志}} {\memgloref{}}|memjustarg}{1}
a.glo
是 UTF-8 编码。 - Cargutf8
编译指示吗?在命令行中添加-Mutf8
选项。 - Håkon HæglandMalformed UTF-8 character (unexpected non-continuation byte 0x7c, immediately after start byte 0xcb) at -e line 1. ee├®
- Carg