草庐IT

get-regexp

全部标签

javascript - 在 RegExp 构建之前清理正则表达式字符串?

我想使用字符串来执行全局正则表达式,但它可能包含正则表达式字符。在使用字符串构建正则表达式之前转义字符串中所有正则表达式字符的最佳方法是什么?基本上我可能有这样的东西;vartest='test.';varregex=newRegExp(test,'ig');我需要“测试”。成为'测试'。所以它不会以意想不到的方式运行。 最佳答案 newRegExp(test.replace(/[#-.]|[[-^]|[?|{}]/g,'\\$&'));或者简单地说:newRegExp(test.replace(/[#-}]/g,'\\$&'));

javascript - 能详细解释下.el, getEl(), Ext.get() 吗?

我是SenchaExtJs的新手我不明白Ext.getCmp('component_id').getEl().hide();行。.getEl()有什么用。我可以直接写Ext.getCmp('component_id').hide();吗?同时向我解释一下.el,Ext.get()。 最佳答案 Ext.getCmp()VSExt.get()Ext.getCmp()在ExtJS组件树中找到一个现有的(创建的)组件。请注意,不鼓励使用它。靠ComponentQuery相反。Ext.get()通过id找到一个DOM元素。例如:Hello,w

javascript - 未知提供程序 : $rootElementProvider when using $injector to get $location service before angular. Bootstrap

您好,我正在尝试手动引导一个Angular应用程序,但有一些业务需要先处理。This文章提到了我感兴趣的技术。当我注入(inject)时:var$injector=angular.injector(["ng"]);var$http=$injector.get("$http");它工作正常,但是:var$injector=angular.injector(["ng","myApp"]);var$location=$injector.get("$location");抛出以下错误。UncaughtError:[$injector:unpr]Unknownprovider:$rootElem

javascript - 用户界面路由器 : How to get next state params in transition

我正在使用ui-router1.0.0.beta.3。如何在转换期间获取下一状态的路由参数?index.run.js$transitions.onStart({to:'**'},verifyAuth);functionverifyAuth(trans){letnextState=trans.$to();if(Auth.verify(nextState.authGroup)===-1){return$state.go('login',{nextState:nextState.name,nextParams:nextState.params});//thisdoesn'twork}}我想存

(已解决)org.springframework.jdbc.CannotGetJdbcConnectionException:Could not get JDBC Connection;nest

记录一个让人气死的错误###Errorqueryingdatabase.Cause:org.springframework.jdbc.CannotGetJdbcConnectionException:CouldnotgetJDBCConnection;nestedexceptionisjava.sql.SQLException:CannotcreatePoolableConnectionFactory(Accessdeniedforuser'root'@'localhost'(usingpassword:YES))###Theerrormayexistincom/itheima/core/da

c# - 使用 GET 的 ASP.Net MVC 模型绑定(bind)复杂对象

我的网络项目中有一个类:publicclassMyClass{publicint?Param1{get;set;}publicint?Param2{get;set;}}这是我的Controller方法中的一个参数:publicActionResultTheControllerMethod(MyClassmyParam){//etc.}如果我使用POST调用方法,模型绑定(bind)会自动工作(我在js端使用angular,这可能无关紧要):$http({method:"post",url:controllerRoot+"TheControllerMethod",data:{myPara

javascript - ES6 做 for of get prototype values - 如何检查 hasownproperty

使用for...in我总是检查hasOwnProperty(我想这是使用Object.keys的一个很好的论据),例如:for(letainobj){if(obj.hasOwnProperty(a)){//logic}}当我使用for...of时是否需要做同样的检查?如果需要,我应该怎么做?根据MDNpageonfor...ofWhilefor...initeratesoverpropertynames,for...ofiteratesoverpropertyvalues但是它没有说明该迭代是包含继承属性还是仅包含实例属性。那里给出的解释和示例代码仅涉及实例属性。

javascript - 将连续的 ","合并为单个 ","并在一个 RegExp 中删除前导和尾随 ","

假设我有一个字符串",,,a,,,,,b,,c,,,,d,,,,"我想把它转换成"a,b,c,d"在1个RegExp操作中。我可以在2个RegExp操作中完成,例如varstr=",,,a,,,b,,,,c,,,,,,,,d,,,,,,";str=str.replace(/,+,/g,",").replace(/^,*|,*$/g,'');是否可以在1个RegExp操作中执行此操作? 最佳答案 您可以使用正则表达式,在开头或后跟逗号或在and处,然后将其替换为空字符串。/^,*|,(?=,|$)/g1stAlternative^,*

javascript - AngularJS - $http get 返回状态为 0 的错误?

我有一个AngularJS应用程序,我在其中尝试使用$http从服务器获取XML数据,例如http://example.com/a/b/c/d/getDetails?fname=abc&lname=def(当通过在浏览器中输入链接手动访问时,会显示XML文件的树结构)。当我运行应用程序时,未从该链接获取数据。相反,它显示一个错误,状态0。//url=http://example.com/a/b/c/d/getDetails?fname=abc&lname=def$http.get(url).success(function(data){alert("Success");deferred

Javascript : get all the object where id is like log_XXXX

我需要获取ID与特定模式匹配的所有对象。我该怎么做?谢谢! 最佳答案 当前浏览器://DOMcollectionasproperarrayconstmatches=Array.from(document.querySelectorAll('[id^=log_]'));旧版浏览器:(IE9+)//UseArray.prototype.slicetoturntheDOMcollectionintoaproperarrayvarmatches=[].slice.call(document.querySelectorAll('[id^=lo