有计算直接扑克牌的正则表达式吗?
我正在使用字符串来表示已排序的卡片,例如:
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值,正则表达式是短的.细节在这里.
谢谢!
在另一个问题中,我学会了如何使用正则表达式计算直接扑克牌(这里).
现在,出于好奇,问题是:我可以使用正则表达式使用ASCII代码计算相同的东西吗?
就像是:
正则表达式:[C] [C + 1] [C + 2] [C + 3] [C + 4],是C的ASCII码(或者像这样)
比赛:45678
,23456
不符合:45679
或23459
(不按顺序)
我想在池中创建无状态bean时创建计时器EJB3.但如果我使用@PostConstruct
我得到例外:
java.lang.IllegalStateException: [EJB:010193]Illegal call to EJBContext method. The bean is in "null" state. It cannot perform 'getting the Timer Service' action(s). Refer to the EJB specification for more details.
如果容器调用@PostConstruct,则bean不为null.那么,为什么我得到这个例外?
类
@Stateless
public class TestBean implements TestLocal {
@Resource
TimerService timerService;
@PostConstruct
public void startTimer() {
if (timerService.getTimers().size() == 0) {
timerService.createTimer(1 * 1000, 1 * 1000, null);
}
}
@Override
public void test() {
}
}
Run Code Online (Sandbox Code Playgroud)
接口
@Local
public interface TesteLocal {
void test();
}
Run Code Online (Sandbox Code Playgroud)
SERVLET
public …
Run Code Online (Sandbox Code Playgroud) 有了这个,
set serveroutput on size 900000;
DECLARE
test VARCHAR(255):=0;
BEGIN
SELECT id INTO test FROM sku WHERE id = 1515;
dbms_output.put_line('Result:' || test);
END;
Run Code Online (Sandbox Code Playgroud)
我有错误
"no data found"
Run Code Online (Sandbox Code Playgroud)
当数据库中不存在ID时.
我怎么能使用nvl()
这里的东西,所以我可以获得默认值而不是出错?
当我改变了我的synonyms.txt时,我只看到了这样做的不同之处:
有些人知道如何在不重启服务器的情况下重新加载synonyms.txt文件?
Tks很多.
我有一个过滤器和controllerName
var获取控制器目标.
例如:当用户尝试访问时/myApp/book/index
,我的过滤器被触发并且controllerName
等于book
.如何获得BookController实例?
TKS
编辑:
我可以得到一个Artefact
使用:
grailsApplication.getArtefactByLogicalPropertyName("Controller", "book")
Run Code Online (Sandbox Code Playgroud)
但是我对这件艺术品做了什么呢?
我在Groovy中有这个代码:
class Person {
def age
Person () {
println age // null
}
}
def p = new Person ([age: '29'])
println p.age // 29
Run Code Online (Sandbox Code Playgroud)
我需要在构造函数中读取年龄值,但它尚未设置.
我怎样才能做到这一点?
注意:我不想使用init()方法并且每次都要手动调用,比如
class Person {
def age
def init() {
println age // now have 29
}
}
def p = new Person ([age: '29'])
p.init()
println p.age // 29
Run Code Online (Sandbox Code Playgroud)
链接到GroovyConsole.
谢谢!
如何知道哪些对象(表/视图/等)使用某个表?
我必须更换我的桌子PRICE.那么,是否有类似的东西?
select system.dependencies from PRICE
Run Code Online (Sandbox Code Playgroud) 我需要一个条件游标,如:
但是看,我不想改变列结果,我想改变整个游标.
贝娄我举了一个更好的例子.
谢谢!
看到:
SET serveroutput ON SIZE 900000;
DECLARE
CURSOR varCursor IS SELECT 1 a FROM DUAL;
-- CURSOR varCursor IS SELECT 2 a FROM DUAL;
BEGIN
FOR varRow IN varCursor LOOP
dbms_output.put_line('row: ' || varRow.a);
END LOOP;
dbms_output.put_line('Done.');
END;
Run Code Online (Sandbox Code Playgroud) 可能重复:
Grails - 从控制器获取消息值
我想在类中使用g.message()方法Service
,而不是Controller
.但我不能.
代码示例:
// this is a method OUTSIDE a Controller
def show = {
def msg = message(code:"foo.bar") // I'm getting error here
}
Run Code Online (Sandbox Code Playgroud)
有可能这样做,或者我必须使用旧ResourceBundle
班级?