FreeKill/docs/diy/09-exppattern.rst

11 lines
634 B
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

.. SPDX-License-Identifier: GFDL-1.3-or-later
解析Exppattern
================
所谓Exppattern类似于各大编程语言中的正则表达式。不过和正则表达式不同的是正则匹配的是字符串而Exppattern匹配的对象是一张张卡牌。通过Exppattern可以判断各种卡牌的情况比如这张牌是否符合“既是红桃也是点数3-5的牌”等等一系列复杂的规则。
你可能也已经注意到了在不少Room中的askFor...函数中出现了很多次pattern参数。这个pattern就是Exppattern它用来辅助确定询问的卡牌必须满足哪些需求。