Different regex behaviour in web page and Chrome extension

I am trying out this regex on this page: http://www.regular-expressions.info/javascriptexample.html where Regex= (?:http://)?(?:www.)?facebook.com/([w-.]*)? and Subject String = http://www.facebook.com/xxxxxx This returns me two matches: http://www.facebook.com/xxxxxx and xxxxxx The same javascript I have embedded in my chrome extension, however there it shows me only one match: 'http

网页和Chrome扩展中的不同正则表达式行为

我在这个页面上试用这个正则表达式:http://www.regular-expressions.info/javascriptexample.html Regex = (?:http://)?(?:www.)?facebook.com/([w-.]*)? 和主题字符串= http://www.facebook.com/xxxxxx 这会返回两个匹配项: http://www.facebook.com/xxxxxx : http://www.facebook.com/xxxxxx和xxxxxx 与我的Chrome扩展中嵌入的JavaScript相同,但是它只显示一个匹配项:'http://www.facebook.com/'。 有任

Javascript: negative lookbehind equivalent?

Is there a way to achieve the equivalent of a negative lookbehind in javascript regular expressions? I need to match a string that does not start with a specific set of characters. It seems I am unable to find a regex that does this without failing if the matched part is found at the beginning of the string. Negative lookbehinds seem to be the only answer, but javascript doesn't have one.

Javascript:负面lookbehind等效?

有没有一种方法可以在javascript正则表达式中实现相当于负向后置的效果? 我需要匹配不以特定字符集开头的字符串。 看来我无法找到一个正则表达式,如果在字符串的开头找到匹配的部分,就不会失败。 消极后验似乎是唯一的答案,但JavaScript没有。 编辑:这是我想工作的正则表达式,但它不: (?<!([abcdefg]))m 所以它会匹配'jim'或'm'中的'm',而不是'jam' Lookbehind Assertio

Referencing nested groups in JavaScript using string replace using regex

Because of the way that jQuery deals with script tags, I've found it necessary to do some HTML manipulation using regular expressions (yes, I know... not the ideal tool for the job). Unfortunately, it seems like my understanding of how captured groups work in JavaScript is flawed, because when I try this: var scriptTagFormat = /<script .*?(src="(.*?)")?.*?>(.*?)</script>/ig; ht

在JavaScript中使用字符串替换使用正则表达式引用嵌套组

由于jQuery处理脚本标记的方式,我发现有必要使用正则表达式来做一些HTML操作(是的,我知道......不是该作业的理想工具)。 不幸的是,似乎我理解捕获的组在JavaScript中的工作方式是有缺陷的,因为当我尝试这样做时: var scriptTagFormat = /<script .*?(src="(.*?)")?.*?>(.*?)</script>/ig; html = html.replace( scriptTagFormat, '<span class="script-placeholder" style="display:none;" tit

Named capturing groups in JavaScript regex?

As far as I know there is no such thing as named capturing groups in JavaScript. What is the alternative way to get similar functionality? ECMAScript 2018 introduces named capturing groups into JavaScript regexes. If you need to support older browsers, you can do everything with normal (numbered) capturing groups that you can do with named capturing groups, you just need to keep track of the

在JavaScript正则表达式中命名捕获组?

据我所知,在JavaScript中没有命名捕获组这样的事情。 什么是获得类似功能的替代方法? ECMAScript 2018向JavaScript正则表达式引入了命名捕获组。 如果您需要支持旧浏览器,您可以使用正常(编号)的捕获组完成所有可以使用命名捕获组的操作,只需要跟踪数字 - 如果在您的捕获组中捕获组的顺序可能会很麻烦正则表达式的变化。 我能想到的命名捕捉组只有两个“结构”优势: 在一些正则表达式(.NET和JGSoft,据我所知)中

capture group still showing in match

I know this topic has been thoroughly covered on StackOverflow, but I can't for the life of me get my regular expression to work. So without further repetitive ado ... This is what I have. String: <p model='cat'></p> Regex: .match(/(?:model=')(.*)(?:')/g) This is what my expression returns: model='cat' This is what I want: cat Why isn't my

仍然在比赛中表现出来的比赛

我知道这个主题已经在StackOverflow中得到了全面的介绍,但是我不能让我的正则表达式正常工作。 所以没有进一步的重复劳动 这是我的。 字符串: <p model='cat'></p> 正则表达式: .match(/(?:model=')(.*)(?:')/g) 这就是我的表达式返回的结果: model='cat' 这就是我想要的: cat 为什么我的非捕获组不被忽略? 难道我不明白什么是非捕获组织? 为什么我的正则表达式不工

What is the difference between $.ajax with type: post and $.post

Consider this code: $.ajax({ url: "http://x.com/api/AnnouncementCategory/Save", type: "Post", success: function (data) { //Grab our data from Ground Control alert(data); }, error: function (event) { //If any errors occurred - detail them here alert("Transmission failed. (An error ha

$ .ajax与类型:post和$ .post之间有什么区别?

考虑这个代码: $.ajax({ url: "http://x.com/api/AnnouncementCategory/Save", type: "Post", success: function (data) { //Grab our data from Ground Control alert(data); }, error: function (event) { //If any errors occurred - detail them here alert("Transmission failed. (An error has occ

Backbone collection in collections

I'm building my first real web app using backbone and I'm struggling with nested resources. This is a simplified version of the json response i'm working with: { "id": 1, "title": "Test Survey", "groups": [ { "id": 1, "title": "Basic Questions", "questions": [ { "id": 1, "title": "Which is your favorite color?" },

集合中的骨干集合

我正在使用骨干构建我的第一个真正的Web应用程序,我正在努力嵌套资源。 这是我正在使用的json响应的简化版本: { "id": 1, "title": "Test Survey", "groups": [ { "id": 1, "title": "Basic Questions", "questions": [ { "id": 1, "title": "Which is your favorite color?" }, { "id": 2, "title": "Do you have any other

"Something" is breaking this jqueryui dialog. What is it?

I don't mean to be vague, but I'm not sure what is going on. This code works: this.J.button_update.click(function () { self.J.dialog_hold.dialog({ resizable: false, modal: true, width: 305, height: 360 }); }); It produces: As you can see there is plenty of room on the right border. What you may not notice is that all my content is off center

“某事”正在打破这个jQuery的对话。 它是什么?

我不是故意模糊的,但我不确定发生了什么。 此代码有效: this.J.button_update.click(function () { self.J.dialog_hold.dialog({ resizable: false, modal: true, width: 305, height: 360 }); }); 它产生: 正如你所看到的,右边框有很多空间。 你可能没有注意到的是,我所有的内容偏离了大约5px。 为了解决这个问题,我想我只是减少5px的jQuery对话框宽度,如下所示:

XMLHttpRequest prototype of onreadystatechange not called

I'm trying to detect when any ajax call finishes in my UIWebView. I modified the code in this answer: JavaScript detect an AJAX event to the best of my abilities. Here is my attempt: var s_ajaxListener = new Object(); s_ajaxListener.tempOnReadyStateChange = XMLHttpRequest.prototype.onreadystatechange; s_ajaxListener.callback = function () { window.location='ajaxHandler://' + this.url;

onreadystatechange的XMLHttpRequest原型未被调用

我试图检测何时在我的UIWebView中完成任何ajax调用。 我修改了这个答案中的代码:JavaScript尽我所能地检测AJAX事件。 这是我的尝试: var s_ajaxListener = new Object(); s_ajaxListener.tempOnReadyStateChange = XMLHttpRequest.prototype.onreadystatechange; s_ajaxListener.callback = function () { window.location='ajaxHandler://' + this.url; }; XMLHttpRequest.prototype.onreadystatechange = function()

attach mousewheel event listener don't reset scroll inertia

I'm using the jquery-mousewheel plugin to trigger a function. When I call moveit I detach the listener and wait until the animation is completed, then I re-attach the listener. The problem is that when I re-attach it, the mousewheel plugin is still listening to the inertia of some mouses/trackpads, and call moveit repeatedly. I guess debouncing or throttling the function call are not go

附加鼠标滚轮事件监听器不重置滚动惯量

我使用jquery-mousewheel插件来触发一个函数。 当我调用moveit时,我会分离侦听器并等待动画完成,然后重新连接侦听器。 问题是,当我重新附加它时,鼠标滚轮插件仍在监听某些鼠标/触控板的惯性,并重复调用moveit。 我想在我的具体情况下去除或限制函数调用并不是很好的解决方案,因为惯性仍然存在,我还希望将侦听器立即连接到其他可能的moveit调用。 有没有办法通过完全重置鼠标滚轮事件来“杀死惯性”,而不是仅仅将它