博饼结果判断的正则表达式

1	1	114444	状元插金花	60
2	2	444444	六勃红	55
3	3	111111	遍地锦	50
4	4	222222|333333|555555|666666	六勃黑	50
5	5	444446	五红带六	45
7	7	344444	五红带三	45
8	8	244444	五红带二	45
9	9	144444	五红带一	45
10	10	111116|222226|333336|555556	五子带六	35
11	11	111115|222225|333335|566666	五子带五	35
12	12	111114|222224|333334|455555|466666	五子带四	40
13	13	111113|222223|355555|366666	五子带三	35
14	14	111112|233333|255555|266666	五子带二	35
15	15	122222|133333|155555|166666	五子带一	35
16	16	444466	四红带十二	30
17	17	444456	四红带十一	30
18	18	444455	四红带十	30
19	19	344446	四红带九	30
20	20	244446|344445	四红带八	30
21	21	1[4]{4}+6|2[4]{4}+5	四红带七	30
22	22	1[4]{4}+5|33[4]{4}+	四红带六	30
23	23	234444	四红带五	30
24	24	13[4]{4}+|22[4]{4}+	四红带四	30
25	25	124444	四红带三	30
26	26	123456	对堂	15
27	27	[^4]*[4]{3}+[^4]*	三红	8
28	28	44[5]{4}+|44[6]{4}+|[1]{4}+44|[2]{4}+44|[3]{4}+44	四进带二举	6
29	29	[1]{4}+.*4.*|.*[2]{4}+.*4.*|.*[3]{4}+.*4.*|.*4.*[5]{4}+.*|.*4.*[6]{4}+	四进带一秀	5
30	30	[^4]*[1]{4}+[^4]*|[^4]*[2]{4}+[^4]*|[^4]*[3]{4}+[^4]*|[^4]*[5]{4}+[^4]*|[^4]*[6]{4}+[^4]*	四进	4
31	31	[^4]*[4]{2}+[^4]*	二举	2
32	32	[^4]*[4]{1}+[^4]*	一秀	1

 

public class GetRoll {

	private List<RollRule> rules;

	public GetRoll(List<RollRule> rules) {
		this.rules = rules;
	}

	private static RollRule nullRollRule = new RollRule("", "没有获奖", 0);

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Pattern p = Pattern.compile("[1]{4}+.*4.*");

		Matcher m = p.matcher("111145");
		GetRoll roll = new GetRoll(new ArrayList<RollRule>());
		System.out.println(m.matches());
		System.out.println(roll.getRoll("444446"));
	}

	public RollRule getRoll(String en) {

		for (RollRule rule : rules) {
			if (isMatch(rule.getRollCode(), en))
				return rule;
		}
		return nullRollRule;
	}

	public ResponseResult getRollResult(String en) {
		String code = excode(en);
		for (RollRule rule : rules) {
			if (isMatch(rule.getRollCode(), code))
				return new ResponseResult(rule, "SUCCESS", code);
		}
		return new ResponseResult(nullRollRule, "SUCCESS", code);
	}

	private static boolean isMatch(String rex, String str) {
		Pattern p;
		Matcher m;
		try {
			p = Pattern.compile(rex);
			m = p.matcher(str);
			return m.matches();
		} catch (PatternSyntaxException pse) {
			// log
		}
		return false;
	}

	private static String excode(String str) {

		if ("".equals(str))
			return "";

		String rtn = "";

		......		
		return rtn.toString();
	}

}



 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值