如何匹配一系列单词与x不同的单词
例如,如何匹配at the cost of后面的单词与some不同
我尝试了以下几点,但都没有结果:
<rule id="AT_THE_COST_OF_!SOME" name="at the cost of !some">
<pattern>
<token>at</token>
<token>the</token>
<token>cost</token>
<token>of</token>
<token regexp="yes">/^((?!some).)*$</token>
</pattern>
<message>Did you mean <suggestion>at the cost of some \5</suggestion>?</message>
<example correction='at the cost of some efforts'>Yes, it comes
<marker>at the cost of efforts</marker>.</example>
</rule>发布于 2016-06-04 15:35:54
LanguageTool在令牌上工作。使用regexp是一种特例,如果使用regexp,则使用单个标记(当使用pattern时)。这将解决您的问题:
<pattern>
<token>at</token>
<token>the</token>
<token>cost</token>
<token>of</token>
<token><exception>some</exception></token>
</pattern>无论如何,要使用正则表达式,请使用<regexp>,如http://wiki.languagetool.org/development-overview#toc8中所记录的那样。
发布于 2016-06-03 18:39:12
传统的正则表达式也可以使用<regexp>标记而不是<token>标记。(但需要LanguageTool 3.2或更高版本才能使用<regexp>)。想了解更多信息- 维基
<regexp>(at the cost of (?!some\b))\w+<regexp>
匹配的模式:
以某人为代价 不惜一切代价
丢弃的模式:
付出一些代价
请测试一下这里
https://stackoverflow.com/questions/37620964
复制相似问题