在Actionscript3和Javascript中,这些语句都给出了相同的结果:
/\S/.test(null) => true
/null/.test(null) => true
/m/.test(null) => false
/n/.test(null) => true
Run Code Online (Sandbox Code Playgroud)
在这种情况下,似乎将null值转换为字符串"null".
这是Ecmascript中的已知错误还是我错过了什么?
我想在PHP中删除网址的第一部分.例:
http://www.domain.com/sales
http://otherdomain.org/myfolder/seconddir
/directory
Run Code Online (Sandbox Code Playgroud)
一定是:
/sales
/myfolder/seconddir
/directory
Run Code Online (Sandbox Code Playgroud)
因为动态的url,我想我必须用preg替换,但我不知道怎么做..有时url已被删除(参见上一个例子).这该怎么做?
我在项目中使用ag-grid插件.我使用$ http服务获取json数据.但网格在网页中显示为空白.但是当直接应用json数据时,网格工作.我想这可能是由于从$ http获取数据的延迟.但是根据角度概念,数据到来时应该更新网格.是否有任何解决方案仅在数据来自服务器时显示html页面.
下面是我的javascript文件'fileBrowser.js':
var fileBrowserModule = angular.module('fileBrowser', ['agGrid']);
fileBrowserModule.controller('fileBrowserController', function($scope, $http) {
$scope.rowData=[
];
$http.get("http://localhost:8080/KKR/flow/sin/allSins.json")
.success(function(data) {
$scope.rowData=JSON.parse("["+JSON.stringify(data)+"]");
console.log($scope.rowData);
});
/*
$scope.rowData=[
{"group":true,"data":{"name":"joe"},
"children":[
{"group":true,"data":{"name":"pat"},
"children":[{"group":true,
"data":{"name":"maya"},
"children":[{"group":false,
"data":{"name":"brook"},
"children":[]},{"group":true,
"data":{"name":"kery"},
"children":[{"group":false,
"data":{"name":"santosh"},
"children":[]}]}]}]},
{"group":false,
"data":{"name":"aravind"},"children":[]}]}
]
*/
var columnDefs = [
{headerName: "Name", field: "name", width: 250,
cellRenderer: {
renderer: 'group',
innerRenderer: innerCellRenderer
}},
{headerName: "Size", field: "size", width: 70, cellStyle: sizeCellStyle},
{headerName: "Type", field: "type", width: 150},
{headerName: "Date Modified", field: "dateModified", width: 150}
];
$scope.gridOptions = …
Run Code Online (Sandbox Code Playgroud) 我正在使用for循环来循环一些具有起始值的元素(在平面上的座位).
这里是:
seatNum - 通过
startSeat 循环的座位数- 开始骑车的座位
我正在从"onsubmit"表单调用该函数.
问题出现在for循环中,当我尝试获取具有id命名约定"s1""s2""s3"等的元素时......"s45""s46"等...基于循环计数器添加到起始座位.计数从0(起始座位)到seatNum(多少个座位).
任何想法为什么id没有正确解决?所有其他工作正常,除了for循环中的最后一个.
是的我是编程的新手,所以我可能没有最佳实践,请在风格上宽容.
function check() {
var startSeat;
var fName = document.getElementById('fName').value
var lName = document.getElementById('lName').value
var address = document.getElementById('address').value
var city = document.getElementById('city').value
var state = document.getElementById('state').value
var zip = document.getElementById('zip').value
var phone = document.getElementById('phone').value
var seatNum = document.getElementById('seatNumber').value
var y=document.getElementById('seatList1').value;
var z=document.getElementById('seatList2').value;
if (z >= y) {
startSeat = y;
}
else {
startSeat = z;
}
if ( (fName == "") || (lName == "") || (address == …
Run Code Online (Sandbox Code Playgroud) 在Python正则表达式中,
re.compile("x"*50000)
Run Code Online (Sandbox Code Playgroud)
给我 OverflowError: regular expression code size limit exceeded
但是下面的一个没有得到任何错误,但它达到了100%的CPU,并在我的电脑上花了1分钟
>>> re.compile(".*?.*?.*?.*?.*?.*?.*?.*?.*?.*?"*50000)
<_sre.SRE_Pattern object at 0x03FB0020>
Run Code Online (Sandbox Code Playgroud)
这是正常的吗?
我应该假设,".*?.*?.*?.*?.*?.*?.*?.*?.*?.*?"*50000
比短"x"*50000
吗?
在Python 2.6,Win32上测试过
更新1:
看起来".*?.*?.*?.*?.*?.*?.*?.*?.*?.*?"*50000
可以减少到.*?
那么,这个怎么样?
re.compile(".*?x"*50000)
Run Code Online (Sandbox Code Playgroud)
它确实编译,如果那个也可以减少到".*?x"
,它应该匹配字符串"abcx"
或"x"
单独,但它不匹配.
那么,我错过了什么吗?
更新2:
我的观点是不知道正则表达式源字符串的最大限制,我想知道"x"*50000
溢出处理程序捕获的一些原因/概念,但不是".*?x"*50000
.
这对我来说没有意义,这就是原因.
在溢出检查中它是缺少的东西或它只是很好或它真的溢出的东西?
任何提示/意见将不胜感激.
我似乎无法在“网络”上的任何地方找到答案...
将函数参数重新声明为局部变量是否有任何原因、优点或缺点?
例子:
function(param1, param2) {
var param1, param2;
...etc...
}
Run Code Online (Sandbox Code Playgroud)
对我来说似乎非常多余,但也许我错过了一些东西......?
谢谢,
布赖恩
我试着
$arr = "one", "two"
$test = [String]::Join(@"\u00A0", $arr)
Run Code Online (Sandbox Code Playgroud)
它给了我
Unrecognized token in source text.
Run Code Online (Sandbox Code Playgroud)
难道是因为我在指定它UTF-8作为0xC2 0xA0
?
http://code.google.com/r/hectorchu-go-windows/source/list
如果你能成功编译,我想知道如何编写程序.
我只是注意到我用python 2.5编写的旧代码现在不起作用.我在python 2.6 btw.
>>> os.spawnl(os.P_NOWAIT,"setup.exe")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\python26\lib\os.py", line 612, in spawnl
return spawnv(mode, file, args)
OSError: [Errno 22] Invalid argument
>>>
Run Code Online (Sandbox Code Playgroud)
任何线索?或者你有任何os.spawn*的工作样本与NOWAIT选项.
更新:
即使我在os.spawnl()中放入完整路径,它仍然是错误的.
根据cairo示例代码,以下代码
double x=25.6, y=128.0;
double x1=102.4, y1=230.4,
x2=153.6, y2=25.6,
x3=230.4, y3=128.0;
cairo_move_to (cr, x, y);
cairo_curve_to (cr, x1, y1, x2, y2, x3, y3);
cairo_set_line_width (cr, 10.0);
cairo_stroke (cr);
cairo_set_source_rgba (cr, 1, 0.2, 0.2, 0.6);
cairo_set_line_width (cr, 6.0);
cairo_move_to (cr,x,y); cairo_line_to (cr,x1,y1);
cairo_move_to (cr,x2,y2); cairo_line_to (cr,x3,y3);
cairo_stroke (cr);
Run Code Online (Sandbox Code Playgroud)
可以生成曲线和两条粉红色的线条.
但那需要4个点,(x,y),(x1,y1),(x2,y2),(x3,y3)
如果我只有x,y和x3,y3(曲线的起点和终点),是否有任何数学公式可以生成那些粉红色的线而不知道x1,y1和x2,y2?
编辑:
它适用于我通过以下方式生成曲线的情况.
cairo_move_to (cr, x, y);
cairo_curve_to (cr, x, y3, x3, y, x3, y3);
Run Code Online (Sandbox Code Playgroud) javascript ×3
regex ×3
python ×2
ag-grid ×1
angularjs ×1
c ×1
c++ ×1
cairo ×1
compilation ×1
function ×1
go ×1
loops ×1
object ×1
php ×1
plane ×1
powershell ×1
preg-replace ×1
pycairo ×1
python-2.6 ×1
variables ×1
windows ×1