Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

正则Rule无效 #24

Open
sang4lv opened this issue Dec 24, 2013 · 3 comments
Open

正则Rule无效 #24

sang4lv opened this issue Dec 24, 2013 · 3 comments

Comments

@sang4lv
Copy link

sang4lv commented Dec 24, 2013

我测试了好多遍还是不知道问题在哪里,真是麻烦大大帮忙看一下。

我从数据库里面调用一条数据,里面有个正则。用的是webot.set插入。大概遇到以下几个问题:
1- 插入时没有错误,但是无法用webot.get获取这条rule
2- 不知为何,只有在处理事件的时候才会调用这条rule。但是由于这是一个正则,所以整个rule都无效了

如果手工创建一条正则rule是正确的。

//数据库拿出来的 - 除了10,其他都调用到了
data.getReplies(function(err, data) {
  if(err) console.log(err);

  console.log('db set');
  console.log(data[10]); //有内容,而且插入时没有报错
  for(var index in data) {
    wechat.set(index, data[index]);
  }
});
console.log('trying to get rule'); //为空
wechat.get(10);
wechat.get('10');

//console
db set
{ pattern: '/[0-9]+/', handler: 'this is a number' }
trying to get rule 
@ktmud
Copy link
Member

ktmud commented Dec 25, 2013

webot.set 传入的 rule name 必须是 string ,试试:

wechat.set(String(index), data[index]);

@sang4lv
Copy link
Author

sang4lv commented Dec 29, 2013

抱歉回复的这么晚,我刚刚试过。即使变成String也无法让rule出现

@ktmud
Copy link
Member

ktmud commented Feb 23, 2014

你再试试 webot.set({ name: index, pattern: '/[0-9]+/', handler: 'this is a number' })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants