gtksourceview で文字列を定義するために、次の短い XML スニペットを使用します。
<context id="string" style-ref="string" end-at-line-end="true">
<start>"</start>
<end>"</end>
<include>
<context id="special-string" style-ref="special">
<match>(foo|bar)</match>
</context>
<context ref="def:line-continue"/>
</include>
</context>
これにより、文字列内の「foo」または「bar」のインスタンスが強調表示されます。これら 2 つが文字列全体であるときに強調表示するとします。つまり、"foo" の中央の 3 文字が強調表示されますが、"foobar" はまったく強調表示されません。これは gtksourceview で可能ですか?
アンカー^...$
と先読み/後読み(?<=")
/を使用してみまし(?=")
たが、前者は機能せず、後者は構文ハイライターを完全に壊しました。