我正试图在R中做一个lookbehind正则表达式来找到一个模式.我希望这会在'bob'中拉出'b',但我得到一个错误.
> regexpr("(?<=a)b","thingamabob")
Error in regexpr("(?<=a)b", "thingamabob") :
invalid regular expression '(?<=a)b', reason 'Invalid regexp'
Run Code Online (Sandbox Code Playgroud)
这不会引发错误,但它也找不到任何错误.
> regexpr("(.<=a)b","thingamabob")
[1] -1
attr(,"match.length")
[1] -1
attr(,"useBytes")
[1] TRUE
Run Code Online (Sandbox Code Playgroud)
我很困惑,因为regexpr的帮助页面明确指出lookbehind应该有效:http://stat.ethz.ch/R-manual/R-patched/library/base/html/regex.html
有任何想法吗?
我有一个表格的视图.我通过以下方式将新模型加载到视图中:
app.fView = new app.FormView({model: new app.aName});
this.$("#formSpace").append(app.fView.render().el);
Run Code Online (Sandbox Code Playgroud)
在initialize我希望它吐出的函数上,initialize form!因为默认名称值是空引号,但我initialize form! undefined建议表单在初始化时没有呈现.
此外,该createOnEnter函数产生所需的输出,但createOnClick返回undefined.我很困惑.
风景:
app.FormView = Backbone.View.extend({
tagName: 'div',
className: 'nameGenForm',
template: _.template($('#form-template').html()),
events: {
"keyup #nameEntry" : "createOnEnter",
"click #addNameButton" : "createOnClick",
"submit #nameEntry" : "submitFail"
},
render: function() {
this.$el.html(this.template(this.model.toJSON()));
return this;
},
initialize: function() {
this.$namein = this.$("#inputName");
console.log('initialize form! ' + this.$("#inputName").val());
},
submitFail: function() {
return false;
},
createOnEnter: function(e) {
console.log('enter! ' + this.$("#inputName").val()); …Run Code Online (Sandbox Code Playgroud)