有计算直接扑克牌的正则表达式吗?
我正在使用字符串来表示已排序的卡片,例如:
AAAAK#sssss = 4 aces and a king, all of spades.
A2345#ddddd = straight flush, all of diamonds.
Run Code Online (Sandbox Code Playgroud)
在Java中,我正在使用这些正则表达式:
regexPair = Pattern.compile(".*(\\w)\\1.*#.*");
regexTwoPair = Pattern.compile(".*(\\w)\\1.*(\\w)\\2.*#.*");
regexThree = Pattern.compile(".*(\\w)\\1\\1.*#.*");
regexFour = Pattern.compile(".*(\\w)\\1{3}.*#.*");
regexFullHouse = Pattern.compile("((\\w)\\2\\2(\\w)\\3|(\\w)\\4(\\w)\\5\\5)#.*");
regexFlush = Pattern.compile(".*#(\\w)\\1{4}");
Run Code Online (Sandbox Code Playgroud)
如何使用正则表达式计算直线(序列)值?
编辑
我打开另一个问题来解决同样的问题,但是使用char的ascii值,正则表达式是短的.细节在这里.
谢谢!